Recently i wanted to get an IP of a domain from within linux command line,
the command is:
Code:
dig +short internetlifeforum.com
but this command returned several IPs one per line. SO icwanted to have only one line in that command output. So i asked Google:
- linux command use only first line output
- how to use only n line out of command result
i found this:
Code:
dig +short internetlifeforum.com | head -n 1
it will return just first line. If one wants to give this IP into variable, it can be done:
Code:
domain=internetlifeforum.com
variablename=$(dig +short $domain | head -n 1)
Bookmarks