這是一段描述如何找出名單中已成功設定domain name 指向 140.128.53.34 的script
ipv4
#!/bin/bash filename='list.txt' exec < $filename while read line do nslookup $line | grep 140.128.53.34 if [ $? == 0 ] then echo $line >> ok_result.txt fi sleep 1 done
grep 符合字串成功的回傳值為 0
藉由 $? 可以得知回傳值
ipv6 使用dig
#!/bin/bash filename="list.txt" ipv6="2001:288:5400:d::34" exec < $filename while read line do #dig lxes.tc.edu.tw AAAA | grep 2001:288:5400:d::34 dig $line "AAAA"| grep $ipv6 if [ $? == 0 ] then echo $line >> ok_result6.txt fi sleep 0.5 done