Skip to content

Instantly share code, notes, and snippets.

@akkaash
Created March 17, 2015 20:34
Show Gist options
  • Save akkaash/e59be9e71b667eb6e4de to your computer and use it in GitHub Desktop.
Save akkaash/e59be9e71b667eb6e4de to your computer and use it in GitHub Desktop.
Ping multiple hosts and extract the average ping time
function do_ping(){
echo $1
ping -c 4 $1 | tail -1| awk '{print $4}' | awk -F '/' '{print $2}'
}
declare -a arr=("google.com" "facebook.com" "linkedin.com")
for i in "${arr[@]}"
do
do_ping "$i"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment