How to write Linux Bash ping Script to ping multiple Servers

Linux Bash scripting is easy and awesome to learn for automation. To write a Linux bash ping script to ping multiple servers or IP addresses, we need some Linux command line such as ping command, echo command, for loop, and sed command or awk command, for organising a clear output results.

Linux Bash Ping Script

It’s the simple Linux bash script to ping multiple servers and displaying the ping output results on the terminal. You can add more function and make it a better Linux bash ping script.

#!/usr/bin/env bash
#Ping Script
for i in {1..5}
do
        echo "Host 192.168.10.$i";
        ping -c 2 192.168.10.$i | sed -n 2,3p;
done
Linux Bash Ping Script - Enlinux
Linux Bash Ping Script – Enlinux

We looking to see your ping bash script on comment section.

Comments

Leave a Comment