Skip to content

Simple bash script for PING list of IP from a text file under linux.

The script and the text file containing the IPs must be in the same folder !

I use this script for ping a list of specific IP address that i keep in a text file. Feel free to use it, not perfect but it works and the job is done. Copy and paste the code in a text file named and do :

chmod u+x

Fill a text file with the IP you want to check like this, name it myaddresses.txt or what you want

After that you just have to :

./ myaddresses.txt

The script

if [ -z $1 ]
        echo -e "\033[1;91mFile with IP is missing\033[0m";
        echo -e 'Example "./ \033[4;31mip.txt\033[0m"';
        exit 1;
awk '{print $1}' < $1 | while read ip; do
    if ping -c 1 -W 0 $ip >/dev/null 2>&1; then
        echo -e "\033[4;32m$ip\033[0m \033[1;94mON LINE\033[0m"
        echo -e "\033[4;31m$ip\033[0m \033[1;91mNOT ON LINE\033[0m"

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: