linux-shell系列1-ip

#!/bin/sh
# Ping网段所有IP

ip1=192.168.30.
ip2=192.168.31.
ip3=192.168.232.
for i in `seq 1 255`
do
ping -c 2 $ip1$i >> /dev/null
if [ $? == 0 ] ;then
echo "$ip1$i" >> /tmp/ip.txt
fi
ping -c 2 $ip2$i >> /dev/null
if [ $? == 0 ] ;then
echo "$ip2$i" >> /tmp/ip.txt
fi
ping -c 2 $ip3$i >> /dev/null
if [ $? == 0 ] ;then
echo "$ip3$i" >> /tmp/ip.txt
fi
done

posted @ 2017-10-31 14:34  划得戳  阅读(193)  评论(0编辑  收藏  举报