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



Robert La Ferla <robertlaferla at comcast.net> writes:

> BTW - That should have been:
>
> cat myfile | sed -e "s/text/\n\ntext/"
>
> but it still doesn't work...

I would do this:
(warning:  there are embedded newlines here)

sed -e 's/text/\
\
text/' myfile

Let me be more illustrative:

sed -e 's/text/\<-LINE ENDS HERE
\<-LINE ENDS HERE
text/' myfile

That's how it is with sed.  OBTW, with some versions of sed your
original might even work.  I am interested in portable sed scripts
though, so I would never rely upon this fact.

In contrast, here is how it would be in Perl:

  perl -pe 's/text/\n\ntext/' myfile

Hope this helps.

Just another Perl hacker,

--kevin
-- 
GnuPG ID: B280F24E                     And the madness of the crowd
alumni.unh.edu!kdc                     Is an epileptic fit
                                       -- Tom Waits




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