[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Sheflug] quick bash question
Hi,
On 29/01/11 20:10, Christopher Brown wrote:
I know the hostname I want to lookup - e.g. mail.lug.org.uk and want
to get the PTR record in one line and the shortest number of
key-strokes as possible.
I can get the IP in one command:
host mail.lug.org.uk
and get the PTR record in another:
dig -x 217.147.93.68
but have no idea how to combine the two or pipe output from the first
to the second. I can probably get it in a single command but would be
interested in the solution anyway.
I'm sure there will be something easier, but one way at least:
dig -x `host mail.lug.org.uk | cut -f 4 -d ' '`
That line is takeing the output from "host mail.lug.org.uk" and piping
it through cut to cut out the 4th item, delimited by spaces, which
happens to be the IP address. Then that is fed onto the command line for
dig.
Hope it helps,
Matt
--
Matt Marsh
Email: matt@xxxxxxxxxxxxxxx XMPP: mattmarsh@xxxxxxxxxx
Mobile: +44 7795 297779 MSN: matt@xxxxxxxxxxxxxxx
Twitter: @marshmn Yahoo: marshmn
Skype: mmarsh_uk
_______________________________________________
Sheffield Linux User's Group
http://sheflug.org.uk/mailman/listinfo/sheflug_sheflug.org.uk
FAQ at: http://www.sheflug.org.uk/mailfaq.html
GNU - The Choice of a Complete Generation