linux中批量测试ip是否在线
1、iP清单、脚本
[root@centos7pc1 test2]# ls ip.txt test.sh [root@centos7pc1 test2]# cat ip.txt www.baidu.com xxxxx www.jd.com yyyyy www.sina.com zzzzz 192.168.209.128 mmmmm [root@centos7pc1 test2]# cat test.sh #!/bin/bash for ip in `cat ip.txt` do ping -c 3 -i 0.2 -w 3 $ip &> /dev/null if [ $? -eq 0 ] then echo "$ip is online!" else echo "$ip is not online!" fi done
2、测试
[root@centos7pc1 test2]# bash test.sh www.baidu.com is online! xxxxx is not online! www.jd.com is online! yyyyy is not online! www.sina.com is online! zzzzz is not online! 192.168.209.128 is online! mmmmm is not online!

浙公网安备 33010602011771号