Danny, On Monday 24 January 2005 14:45, Danny Sauer wrote:
...
sed -e 's/.*cn=[^,][^,]*,.*//' logFile
Adjust it as necessary if you want a different field.
Are you sure that won't need adjusted regardless of the desired field?
:) That'll just erase the whole line, unless your sed is different
D'Oh!
from mine.
You may have meant sed -e 's/.*cn=\([^,][^,]*\),.*/\1/' logfile Or, even better, sed -ne 's/^.*cn=\([^,][^,]*\),.*$/\1/p' logfile
Yes, though the second form is a distinction without a difference in this case.
I'd also include the line beginning and ending anchors, to explicitly match the whole line (I don't like being ambiguous), and use the -n option so it'll only print matching lines (when paired with the /p after the regex).
--Danny, who would've used perl...
Randall Schulz