It may be a job for sed in this case because, my /etc/resolv.conf has two lines before the actual dns addresses.
Head -n3 /etc/resolv.conf will also print those first two lines.
For example: I put it in file.txt and changed the names to protect the innocent.
cat file.txt
; generated by /sbin/dhclient-script
search ab.some.place.us
nameserver 123.123.123.12
nameserver 145.145.145.14
nameserver 122.122.122.12
head -n3 file.txt | cut -d" " -f2
generated
ab.some.place.us
123.123.123.12
Using sed, I can pick out one or more lines individually....
Code:
sed -n 3p file.txt | cut -d" " -f2
123.123.123.12