ps:需要在同一目录底下新建一个1.txt的文件然后执行sh ping.sh 1.txt即可 #!/bin/bash. /etc/init.d/functionsfor ip in `cat 1.txt`do echo "Test $ip if is alive" ping $ip -c1 &>/dev/null if [ $? -gt 0 ];then echo "$ip ping不通!!!!" continue else echo "ok" fidone