ping.sh
#!/bin/bashfor i in {1..193}do( ping -c1 -i0.2 -w1 172.16.30.$i &>/dev/nullif (( $?==0 ))thenecho "172.16.30.$i up" >>2.txtelseecho "172.16.30.$i down" >>3.txtfi )& --》这样就把这一段放到后台去执行了,大大加快了速度。donesleep 2live_pc_num=`cat 2.txt|wc -l`down_pc_num=`cat 3.txt|wc -l`echo "there are $down_pc_num is down"echo "there are $live_pc_num is up"echo "list:"cat 2.txtrm -rf 2.txt 3.txt
break 停止循环
#!/bin/bashi=1while :doecho "$i"(( i++ ))if (( i==20000 )) --》输出的只有1-19999thenbreakfidone
