cat IPList | while read line
do
if ping -c 1 $line >/dev/null 2>&1 ; then
echo "$line yes"
else
echo "$line no!"
fi
done
输出:
172.2.56.90 yes
172.2.56.91 no!
172.2.56.92 yes
172.2.56.93 yes
172.2.56.94 no!
172.2.56.95 yes
172.2.56.96 yes
172.2.56.97 no!
注:IPList是IP列表,每行一个