I'd like to be able to return only the IP from a nslookup command. Currently if I execute:
>nslookup foo21.bar.local
it will return something like:
Server: 11.13.5.134
Address: 11.13.5.134#53
Name: foo21.bar.local
Address: 11.13.35.312
I would like a command that returns just the:
11.13.35.312
Thanks for any answers.
dig
has options to make that easy:
dig +short foo21.bar.local
will just give you the A records, one per line (a domain can have more than one A record). To only get the first one:
dig +short foo21.bar.local | head -n1