[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Sed newline
From: |
Derose, Steve \(NIH/NLM/NCBI\) [C] |
Subject: |
Sed newline |
Date: |
Mon, 12 Dec 2005 12:07:15 -0500 |
I understand that sed is supposed to allow you to insert a newline via
the s command, by putting backslash and an actual end of line in a
script.
Here, it works under tcsh and sh, but not bash (which is the local
default).
With bash, for the script:
#!/bin/tcsh
# test if sed can insert a newline.
cat $* | sed 's/here/\
here/g'
I get:
sed: -e expression #1, char 7: Unterminated `s' command
If I switch to double quotes, bash instead silently fails to insert the
newlines.
Please consider adding numeric escapes for inserting untypable
characters into the s command. This would be less prone to shell
dependencies, and
provide a workaround for any kind of odd character problems that may
crop up.
In fact, I think it would be really great if a single escaping mechanism
were introduced into *all* linux commands (well, I suppose 'yes' would
be kind of pointless...) -- that way I'd never have to remember which
ones takes which mechanism. No need to take out other existing ones, but
why not have a single
unescaping library routine, that eventually gets used by everything that
might need escaping at all?
But sed is the biggest need I run into (there being no cleaner way I've
found to insert newlines before any string or regex I want).
Thanks!
Steve DeRose
Steve DeRose (contractor)
National Center for Biotechnology Information
address@hidden <mailto:address@hidden>
- Sed newline,
Derose, Steve \(NIH/NLM/NCBI\) [C] <=