Digging to the final IP
Niall O'Reilly
niall.oreilly at ucd.ie
Thu Oct 23 23:30:53 UTC 2014
At Thu, 23 Oct 2014 15:17:49 +0100,
Sam Wilson wrote:
>
> In article <mailman.1128.1414072988.26362.bind-users at lists.isc.org>,
> Bob Harold <rharolde at umich.edu> wrote:
>
> > Anytime you see 'grep' and 'cut' used together, they can usually be
> > shortened to just 'awk', which requires starting one less process. And if
> > this case it splits fields the way a users sees them, so the same code
> > works in both cases:
> >
> > $ dig +noall +answer home.kreme.com in a | awk '/[\t ]A[\t ]/ {print $NF}'
> > 23.24.150.141
> > $ dig +noall +answer dave.knig.ht in a | awk '/[\t ]A[\t ]/ {print $NF}'
> > 216.235.14.46
>
> $ dig +noall +answer cancer.ucs.ed.ac.uk | perl -ne ' /\sA\s/ && do {
> @_=split; print "$_[$#_]\n" }'
> 129.215.166.13
> 129.215.200.7
Which makes it easy, in either case, to return a status value, as
Frank Bulk seemed to want.
Something like
'... {print $NF; count++} END {exit ! count}'
or
| perl -ane ' /\sA\s/ && do { print "$F[$#F]\n"; $count++ } END
{exit ! $count }'
might work.
Niall
More information about the bind-users
mailing list