I want to set the first line of the following dig
command output to a variable:
root@kali:~# dig +short stackoverflow.com
151.101.129.69
151.101.65.69
151.101.1.69
151.101.193.69
So it outputs so many IP adresses, but I want only the first one which can be done by sed
or head
like shown below:
root@kali:~# dig +short stackoverflow.com | sed -n 1p
151.101.193.69
Problem:
When I set this to a variable, it gives me all IP adresses:
root@kali:~# cmd='dig +short stackoverflow.com | sed -n 1p'
root@kali:~# $cmd
151.101.129.69
151.101.65.69
151.101.1.69
151.101.193.69