Holger Kubiak wrote: > If the package host is installed I get: > holger@myhost:~$ host 193.99.144.71 > Name: www.heise.de > Address: 193.99.144.71 > > If the package bind9-host is installed I get: > holger@myhost:~$ host 193.99.144.71 > 71.144.99.193.in-addr.arpa domain name pointer www.heise.de. > > I wanted to grep and awk the output. As you can see this will be > difficult. Not too difficult. I have been using the following in a script which I needed for similar reasons. host 193.99.144.71 | awk '/Name:/||/domain name pointer/{print$NF;exit}' www.heise.de # host www.heise.de. # bind9-host The only difference is that bind9-host will leave a dot on on the end of the name. Depending upon your needs you need to be aware of that possibility. Assuming 'h' is a variable holding this name then 'h=${h%.}' should ensure no trailing dot regardless of which host is installed. I rather like the 'dig' solutions posted by others. I really just posted this because I wanted to share the simple awk solution. But now I am thinking seriously of converting to the dig solution myself. :-) Bob
Attachment:
pgpr8XpjP_gIr.pgp
Description: PGP signature