Re: Awk help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On Mon, Jun 23, 2008 at 11:25:45AM -0600, Joseph L. Casale wrote:
> I have csvde dump from active directory I process on my postfix mta.
> It takes output like this:
> 
> "CN=Curtis xxx,OU=Domain Users,OU=xxx xxx,DC=xxx-xxx,DC=local",X400:c=US\;a= \;p=xxx xxx xxx\;o=Exchange\;s=xxx\;g=xxx\;;SMTP:Cxxx@xxxxxxxxxxx
> 
> and should return a relay_recipient map in the form of:
> Cxxx@xxxxxxxxxxx     OK
> 
> The command I am using is:
> cat $1 | tr -d \" | tr , \\n| tr \; \\n | awk -F\: '/(SMTP|smtp):/ {printf("%s\tOK\n",$2)}'

Use sed instead:
   sed -n 's/^.*;;SMTP:\(.*\)$/\1 OK/p' < $1

> Everything up to the awk is working, it drops the smtp: but its putting OK's all over the darn place.
> Anyone familiar enough with awk and printf that can suggest why this happens?

It works OK on the test line you provided; my guess is your datafile
has other lines that match "SMTP" in other fields of the source.

-- 

rgds
Stephen
_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux