一、
#!/bin/bash
for i in $(seq 1 254)do
{
IP="192.168.191.$i"
ping $IP -c1 -s1 2>&1 1>/dev/null && echo -e $IP is "alive" || echo -e $IP is "down"
} &
done
wait
二、
#!/bin/bsh
prefix=192.168.1
octet=1
while [ "$octet" -lt "255" ]; do
echo -en "Pinging ${prefix}.${octet}..."
ping -c1 -w1 ${prefix}.${octet} >/dev/null 2>&1
if [ "$?" -eq "0" ]; then
echo " ok"
else
echo " failed"
fi
let octet=$octet+1
done