#!/bin/bash
net=192.168.40.
ip=0
while [ $ip -lt 200 ]
do
let ip++
sleep 0.5
if `ping -c2 -i0.2 -w2 $net$ip &>/dev/null`
then echo "$net$ip is up"
else
echo "$net$ip is down"
fi
done
echo "end"
**
多进程版
**
#!/bin/bash
net=192.168.40.
for((i=1;i<201;i++))
do
{
sleep 0.5
if `ping -c2 -i0.2 -w2 $net$i &>/dev/null`
then echo "$net$i is up"
else
echo "$net$i is down"
fi
}&
done
wait
echo "end"