Appending text in a file

Steven Elling ellings at kcnet.com
Sat Apr 26 07:27:53 CDT 2003


On Friday 25 April 2003 17:03, Jason Clinton wrote:
> Steven Elling wrote:
> > Just do the following in your case:
> >
> > cat old.ldif | > > sed -e 's/(dn:.*)/1,ou=contacts,dc=tarcanfel,dc=net/' > new.ldif
>
> Hehe. "Just..." If it's any consolation, Jonathan, I look at lines like
> this and my eyes cross too. :)

Just be glad this substitute expression doesn't suffer from the leaning 
toothpick syndrome.

As a side note: I did not realize it at first, but, you can use more than just 
the forward slash to delimit the pieces of the expression.  The above will 
work this way too:

cat old.ldif | sed -e 's#(dn:.*)#1,ou=contacts,dc=tarcanfel,dc=net#' > new.ldif

Notice how I used the hash mark to delimit the pieces of the expression.  
Sometimes this makes substitute expressions a little easier to read when 
using a lot of slashes and back-slashes.




More information about the Kclug mailing list