Appending text in a file
Hal Duston
hduston at speedscript.com
Fri Apr 25 21:18:02 CDT 2003
On Fri, 2003-04-25 at 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.
Something like (untested):
sed '/^dn:/s/$/,ou=contacts,dc=tarcanfel,dc=net/' < input > output
should to the trick.
Annotations:
/^dn:/ -- For each line beginning with dn:
s -- substitute
$ -- At the end of the line
,ou... -- This text.
< -- Input file
> -- Output file.
--
Hal
More information about the Kclug
mailing list