Advertisement
Guest User

Untitled

a guest
Oct 15th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.34 KB | None | 0 0
  1. rtt() { local h="$1" c="${2:-1}"; if [ -z "$h" ]; then return 1; fi; printf "%s %s\n" "$h" "$(ping -W1 -c "$c" "$h" | awk '/rtt/{ gsub("/", " ", $4); print $4 }')"; };
  2. sort-by-rtt() { mapfile hosts; while read -r h _; do rtt "$h" & done < <(printf "%s\n" "${hosts[@]}") | sort -nk2; wait; }
  3. # sort-by-rtt < <( awk '{print $2}' ~/.hosts | shuf -n3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement