#!/bin/bash for IP in `cat /root/Desktop/ip.txt` do ping -c 3 -i 0.2 -w 3 $IP &> /dev/null if [ $? -eq 0 ] then echo "This host $IP is existed" else echo "This host $IP isn‘t existed" fi done
ping 检测,for循环
原文:https://blog.51cto.com/sampsondotqiu/2490643