Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

sed replacement



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




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org