Skip to content

Instantly share code, notes, and snippets.

@mizzunet
Created April 15, 2022 01:28
Show Gist options
  • Save mizzunet/7fa6e780e750bf183dc9e25f1e6fa466 to your computer and use it in GitHub Desktop.
Save mizzunet/7fa6e780e750bf183dc9e25f1e6fa466 to your computer and use it in GitHub Desktop.
Ping multple servers and sort
#!/bin/bash
o=output
cap=10
for server in $(cat servers)
do
ping=$(ping "$server" -c $cap)
avg=$(echo $ping| grep avg | cut -d'/' -f 5)
if [[ "$avg" != "" ]]; then
echo "$avg $server"
echo "$avg $server" >> $o
fi
done
sort $o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment