Quote:
Originally Posted by Christoph Spohr
Hi,
under bash you can try
dns=( $(awk '/nameserver/{print $2}' /etc/resolv.conf ) )
This will give you the second field of all lines matching nameserver read into an array. You can access the data with: echo ${ dns[0]}, ${ dns[1]} etc.
Kind regards
Chris
|
Thanks that works but it doesn't like it if the file is empty. I guess I can do my standard grep nameservers | wc -l to check if there is an entry first.