For loop in BASH Ping for rage in answer show up.
Posted on: 7 February 2015 /
Categories:
This step-by-step article describes how to ping a remote Internet Protocol (IP) address by using a for loop in bash.
for ip in $(seq from-to rage ); do ping -c1 YOUR_UP.$ip>/dev/null; [ $? -eq 0 ] && echo “192.168.1.$ip UP” || : ; done
example:
for ip in $(seq 120 123 ); do ping -c1 192.168.1.$ip>/dev/null; [ $? -eq 0 ] && echo “192.168.1.$ip UP” || : ; done