There are many tools to implement this, and yeah, this is not the fastest. But the advantage is that you don't need extra tools beyond "bash" and "ping"...
for i in $(seq 1 254); do
if ping -W 1 -c 1 192.168.0.$i; then
HOST[$i]=1
fi
done
echo ${!HOST[@]}
will give you the host addresses for the machines that are live on a given network...
!/usr/bin/bash
for i in {1..254}; do if ping -W 1 -c 1 192.168.0.$i; then HOST[$i]=1 fi done echo ${!HOST[@]}
you forget to mention seq as an extra tool
or just use pure bash: for i in {1..254}; do
Hi,
is "-W 1" used so that there's enough time to get a reply from hosts which don't have the ARP in the ARP table (therefore requiring an additional ARP request)?