循环ping,检测ip是否可用,ping通为正在使用yes,no为不通
vim test.sh
#!/bin/bash
ip="192.168.1."echo "ping log:" > ./ping.txt
for i in {1..128}
doping -c 1 -w 1 -W 1 $ip$i | grep -q "ttl=" && echo "$ip$i [yes]" >> ./ping.txt || echo "$ip$i [no]" >> ./ping.txt &
done
echo "wait 5s...."
sleep 5
cat ./ping.txt
cat ./ping.txt | wc -l