ping.sh
#!bin/bash
#ping host ip
for hostip in {1..254};
do
ip="172.20.100.$hostip"
ping -c 1 -W 2 $ip &> /dev/null
if [ "$?" == "0" ];then
echo $ip is UP
echo -e "ip:$ip up" | tee -a up.txt
else
echo $ip is DOWN
echo -e "ip:$ip down" | tee -a down.txt
fi
done