#!/bin/bash [[ -z $1 ]] && echo mirror file? && exit 1 mirror_file=$1 echo sorting best mirrors for mirror in `grep -vE '^#|^$' $mirror_file`; do ping -c1 -W1 $mirror | grep time= 2>/dev/null done | sort -bV -k 4 -t '='; unset mirror