0
Using awk with bash variables
I wanted to use variables in a bash script’s for loop inside awk’s print statement.
Here’s an easy way to do it – enclose the bash variable within "’"
Here’s a sample scripts to take a list of IPs and do a DNS lookup and generate a CSV:
for ip in `cat ips.txt`
do
host $ip|grep -v NXDOMAIN|sed 's/\.$//g'|awk '{print "'"$ip"'"","$NF}'
done