Appending text in a file
Steven Elling
ellings at kcnet.com
Fri Apr 25 21:34:51 CDT 2003
On Friday 25 April 2003 15:41, Jonathan Hutchins wrote:
> I have an LDIF file with a bit over 300 entries. I need to append some
> text (",ou=contacts,dc=tarcanfel,dc=net") to each line that begins with
> "dn:".
>
> Surely there's an easy way to script this.
>
> Using sed, I can append text, but only as the next line.
What --- Only as the next line!?
sed will allow you to insert text anywhere.
Just do the following in your case:
cat old.ldif | sed -e 's/(dn:.*)/1,ou=contacts,dc=tarcanfel,dc=net/' > new.ldif
More information about the Kclug
mailing list