#!/bin/bash servers=('nbg.icmp.hetzner.com' 'fsn.icmp.hetzner.com' 'hel.icmp.hetzner.com' 'ash.icmp.hetzner.com' 'dismyserver.net') names=('Nuremberg' 'Falkenstein' 'Helsinki' 'Ashburn, VA' 'OVH Canada') regex="time=[0-9 \.]+ms" for index in $(seq 0 $((${#servers[@]}-1))); do domain=${servers[$index]} name=${names[$index]} pingdata=`ping -c1 ${domain}` delay=`echo -e $pingdata | egrep -o "${regex}"` [ ${#domain} -lt 20 ] && tabs="\t\t" || tabs="\t" echo -e "${name}\t${domain}${tabs}${delay}" done