Randall R Schulz wrote:
James, Ryan,
On Monday 24 January 2005 13:29, James Knott wrote:
Ryan McCain wrote:
I have a file that has 100 or so lines in this format:
dn: cn=SERVERNAME1,ou=NWSERVERS,ou=SERVER03,ou=iServices,ou=MON,o=LA dn: cn=SERVERNAME2,ou=NWSERVERS,ou=SERVER03,ou=iServices,ou=MON,o=LA dn: cn=SERVERNAME3,ou=NWSERVERS,ou=SERVER03,ou=iServices,ou=MON,o=LA
How can I strip out everything execpt the servername? Using either shell scripting, sed or perl?
man cut
Cut is limited in its ability to delineate fields. It can use fixed character positions or a specific field separator character, but not a multi-character pattern such as "cn=".
With a bit of manipulation, you can for example, select "=" as the first delimiter, then "," as the next. You'd cut on "=", selecting everything after the cut, then pipe through another cut, using "," and selecting everything before the cut. I did something like that a while ago.