sed replacement
David Hummel
dhml at comcast.net
Mon May 16 11:38:46 EDT 2005
On Mon, May 16, 2005 at 09:31:33AM -0400, Robert La Ferla wrote:
>
> cat myfile | sed -e "s/text/\n\ntext/"
I believe this will only work with GNU sed.
But sed works on each line of input, so you need to address only the
first line:
$ cat myfile | sed "1s/^/\n\n/"
For sed on Solaris 9, this will work:
$ cat myfile | sed '1s/^/\
> \
> /'
Note the single quotes to avoid escaping by the shell.
The double-quote version:
$ cat myfile | sed "1s/^/\\
> \\
> /"
And in perl:
$ perl -pe "BEGIN {$/ = undef;} s/^/\n\n/;" myfile
I'm sure there are other ways, including using awk, etc.
-David
More information about the Discuss
mailing list