[clue-tech] Script Help

David Anselmi anselmi at anselmi.us
Tue May 10 22:27:01 MDT 2005


Ballon, Mike wrote:
[...]
> Matched 'cn=userb,cn=Recipients,ou=somthing,o=something else' to
> 'CN=userb,OU=office,OU=office2,OU=Users and Groups,DC=domain,DC=com' based
> on SID.
> Matched 'cn=userc,cn=wayway,cn=outeast,ou=something,o=something else' to
> 'CN=userc,OU=outeast,OU=support,OU=Users and Groups,DC=domain,DC=com' based
> on SID.
>  
> PARSE
> cat ez.log | grep Matched | awk -F"[Cc][Nn]=" '{print $2 $4}' | awk -F","
> '$1 != $2 {print $1","$2}'

A guy I work with likes to do:

grep foo | awk '{print $x}'

and I'm trying to teach him that:

awk '/foo/ {print $x}'

is more concise.  I guess he's just too young to have any use for awk 
(which may not be a bad thing).

Looks to me though like your user id always follows '[cC][nN]= so:

sed "s/^Matched 'cn=\([^,]*\),.*'CN=\([^,]*\).*$/\1 \2/" ez.log \
   | awk '$1 != $2 {print}'

Adjust cn and CN if you can't count on their case.  And if that regex is 
too ugly for you, go get perl.

Dave



More information about the clue-tech mailing list