一个简单的找出网段内存活主机的脚本
for循环, 0.1 -- 0.254 依次去ping,能通说明在线
#!/bin/bash ips="192.168.1." for i in seq 1 254
do ping -c 2 $ips$i >/dev/null 2>/dev/null if [ $? == 0 ] then echo "echo $ips$i is online" else echo "echo $ips$i is not online" fi done
for循环, 0.1 -- 0.254 依次去ping,能通说明在线
#!/bin/bash ips="192.168.1." for i in seq 1 254
do ping -c 2 $ips$i >/dev/null 2>/dev/null if [ $? == 0 ] then echo "echo $ips$i is online" else echo "echo $ips$i is not online" fi done