Created
April 15, 2022 01:28
-
-
Save mizzunet/7fa6e780e750bf183dc9e25f1e6fa466 to your computer and use it in GitHub Desktop.
Ping multple servers and sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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