ping主机脚本
#!/bin/bash #ping net='172.16.1' uphosts=0 downhosts=0 for i in {1..254};do ping -c 1 -w 1 ${net}.${i} &> /dev/null if [ $? -eq 0 ];then echo "${net}.${i} is up." let uphosts++ else echo "${net}.${i} is down." let downhosts++ fi done echo "Up hosts:$uphosts" echo "Down hosts:$downhosts" ~