自动判断局域网内在线的主机数目
目的:自动查询局域网内在线的主机数目。
#!/bin/bash
for I in {1..254};do
if ping -c1 -W 1 192.168.6.$I &>/dev/null;then
echo "the host 192.168.6.$I is exist"
else
echo "the host 192.168.6.$I is not exist"
fi
trap 'exit' SIGINT
done
转载于:https://blog.51cto.com/haoxiaoyang/959437