批量检测在线主机,运行效果
vim check_ip.sh
#!/bin/bash
. /etc/init.d/functions
ip=192.168.31.
for i in {1..100}
do
if ping -c 1 $ip$i &>> /dev/null ;then
echo -n " $ip$i"
success
echo " "
else
echo -n " $ip$i"
failure
echo " "
fi
done
取出在线的主机及ip
bash check_ip.sh > ip.txt
grep "确定" ip.txt