I’m very new to linux and bash. I’m trying to find a domain name for an ip address. When I use nslookup I have a bunch of lines like this
nslookup 204.228.150.3
Output
Server: 198.60.22.2 Address: 198.60.22.2#53 Non-authoritative answer: 3.150.228.204.in-addr.arpa name = www.computerhope.com. Authoritative answers can be found from: 150.228.204.in-addr.arpa nameserver = ns.xmission.com. 150.228.204.in-addr.arpa nameserver = ns1.xmission.com. 150.228.204.in-addr.arpa nameserver = ns2.xmission.com. ns.xmission.com Internet address = 166.70.254.2 ns1.xmission.com Internet address = 204.228.159.2 ns2.xmission.com Internet address = 207.135.133.2
I only want to print www.computerhope.com in the second line. How do I do this? Also I tried to use host command as well. It looks cleaner.
206.153.126.75.in-addr.arpa domain name pointer www.cyberciti.biz.
How do I only print www.cyberciti.biz when I use host command ? PLease help
Advertisement
Answer
$ host 75.126.153.202 |sed -e 's/.* //' www.cyberciti.biz.