Digging to the final IP
Bob Harold
rharolde at umich.edu
Thu Oct 23 14:03:01 UTC 2014
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
--
Bob Harold
hostmaster, UMnet, ITcom
Information and Technology Services (ITS)
rharolde at umich.edu
734-647-6524 desk
On Wed, Oct 22, 2014 at 6:58 PM, LuKreme <kremels at kreme.com> wrote:
>
> > On 21 Oct 2014, at 22:46 , Jim Young <jyoung at gsu.edu> wrote:
> >
> > On 10/22/14 12:08 AM, "LuKreme" <kremels at kreme.com> wrote:
> >
> >>> On 21 Oct 2014, at 19:20 , Dave Knight <dave at knig.ht> wrote:
> >>>
> >>> $ dig +noall +answer dave.knig.ht in a | egrep 'IN\tA\t' | cut -f6
> >>> 216.235.14.46
> >>
> >> Interesting. This works for me:
> >>
> >> dig +noall +answer home.kreme.com in a | egrep '\tA' | cut -f5
> >>
> >> but on your example, it requires -f6
> >>
> >> And yet, the outputs appear to have the same number of fields.
> >>
> >> $ dig +noall +answer www.kreme.com in a
> >> www.kreme.com. 21139 IN CNAME cerebus.kreme.com.
> >> cerebus.kreme.com. 21141 IN A 23.24.150.141
> >> $ dig +noall +answer dave.knig.ht in a
> >> dave.knig.ht. 13916 IN CNAME sb.sanxion.org.
> >> sb.sanxion.org. 222 IN A 216.235.14.46
> >>
> >> Very odd.
> >
> > Subtle formatting difference for human consumption. There are a variable
> > number of ASCII TABs inserted to visually align fields.
>
> Yeah, I saw the extra space after 222, but did not check for a second tab
> following sb.sanxion.org.
>
> > This is where output generated for human consumption can be tricky to
> > parse.
>
> That’s why I like dig +short
>
>
> --
> BART BUCKS ARE NOT LEGAL TENDER Bart chalkboard Ep. 8F06
>
> _______________________________________________
> Please visit https://lists.isc.org/mailman/listinfo/bind-users to
> unsubscribe from this list
>
> bind-users mailing list
> bind-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/bind-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/bind-users/attachments/20141023/b4e85906/attachment.html>
More information about the bind-users
mailing list