[Gllug] Help with sed
Stig Brautaset
gllug at brautaset.org
Fri Apr 11 23:33:37 UTC 2003
> dn: cn=Bob Smith,ou=contacts,dc=mydomain,dc=org
> changetype: add
> company: MyCompany
...
> dn: cn=Bob Smith,ou=contacts,dc=mydomain,dc=org
> changetype: modify
> replace: company
> company: A Different Company
...
> So the trick is identify all the "changetype: add" lines and replace them
> with the last 3 lines in the second example (does that make sense????)
>
> I'm sure you guys will crack this in a second but sed makes my head hurt!
This is probably a bad case of giving you what you asked for instead of
what you actually meant, but here it goes:
sed -e \
's,^changetype: add$,changetype: modify\nreplace: company\ncompany: A different Company,' \
oldfile > newfile
To get rid of the old company lines, use:
sed -e '/company: MyCompany/d' oldfile > newfile
Stig
--
brautaset.org
--
Gllug mailing list - Gllug at linux.co.uk
http://list.ftech.net/mailman/listinfo/gllug
More information about the GLLUG
mailing list