help with AWk

Eric Schuele e.schuele at computer.org
Sun Sep 28 04:12:10 UTC 2008


On 09/27/2008 22:06, Len Conrad wrote:
> The logic desired if
> 
> If IP has no PTR, print "PTR_NUL", else print the PTR.
> 
> 
> dig +short -x 1.2.3.4 | awk '{if ( $0 == "" ) {print "PTR_NUL" } else {print $0 } }'
> 
> ... works if PTR exist, but if no PTR, PTR_NUL doesn't print.

A workaround that does the trick...

printf "dug `dig +short -x 1.2.3.4`" | awk '{if ( NF == 1 ) {print
"PTR_NUL" } else {print $2 } }'

> 
> thanks
> Len
> 
> 
> 
> 
> 
> ______________________________________________
> IMGate OpenSource Mail Firewall www.IMGate.net
> 
> _______________________________________________
> freebsd-questions at freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-questions
> To unsubscribe, send any mail to "freebsd-questions-unsubscribe at freebsd.org"
> 
> 


-- 
Regards,
Eric


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20080928/b8806714/signature.pgp


More information about the freebsd-questions mailing list