Link to home
Start Free TrialLog in
Avatar of NetRock6
NetRock6Flag for Canada

asked on

AWK: Insert a new line after each line

Hi ..
I am trying to query the nameserver ips from /etc/resolv.conf file and then create a file as below:
dns1 10.10.10.1
dns2 10.10.10.2
dns3 10.10.10.3
dns3 10.10.10.3

Open in new window


using the below code, I am able to query the ips but i need help to create a file as shown above.
ns=$(cat /etc/resolv.conf  | grep -v '^#' | grep nameserver | awk '{print $2}') 

Open in new window


Could someone please help.
Thanks
ASKER CERTIFIED SOLUTION
Avatar of Gerwin Jansen
Gerwin Jansen
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NetRock6

ASKER

dns1 10.10.10.1
dns2 10.10.10.2
dns3 10.10.10.3
dns3 10.10.10.3

Open in new window


As above.
Thanks
Yes, the cat command above does exactly that.