#!/bin/bash for i in `seq 1 254` do ping -c 1 192.168.192.$i > /dev/null if [ $? -eq 0 ];then echo "ping 192.168.192.$i成功" else echo "ping 192.168.192.$i失败" >> /root/a.txt fi done
#!/bin/bash for i in `seq 1 254` do ping -c 1 192.168.192.$i > /dev/null if [ $? -eq 0 ];then echo "ping 192.168.192.$i成功" else echo "ping 192.168.192.$i失败" >> /root/a.txt fi done