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列表,每行一个
本文介绍了一个简单的Shell脚本,通过读取IPList文件中的每一行IP地址,使用ping命令检查网络可达性。对于每个IP,如果能ping通,则输出'yes',否则输出'no'。脚本结果显示了哪些IP地址是可以成功ping通的,哪些是无法连接的。
984

被折叠的 条评论
为什么被折叠?



