Skip to content

Instantly share code, notes, and snippets.

@vivisidea
Created September 13, 2014 02:52
Show Gist options
  • Save vivisidea/0b17eb78be7c45d032f6 to your computer and use it in GitHub Desktop.
Save vivisidea/0b17eb78be7c45d032f6 to your computer and use it in GitHub Desktop.
simple shell script to find the min-average ping rtt time from multiple ips
#!/bin/bash
# file: ping-shortest
# created by make-template :)
# vivi@2014-06-29_18:16:12
ipfile=ips.txt
tmp=ping-ip-tmp.txt
while read IP; do
average=`ping -nq -w 1 -i 0.2 -c 3 $IP | grep rtt | cut -d '/' -f 5`
if [ "X$average" == "X" ]; then
continue
fi
echo $average $IP
done < $ipfile
@vivisidea
Copy link
Author

ping-shortest | sort -n

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment