测试域名ping延迟脚本

#!/bin/bash

if [ $# -lt 1 ]
then
echo "Usage:avg file1"
exit 1
fi
echo "====================`date`======================" >> result.txt
function main {
 time=`ping -c 10 -i 0.1 -q $1 | egrep "^rtt" | awk -F/ '{print $5}'`
 [[ "${time}" == "" ]] && echo -e "$1 time_out" >>result.txt || echo -e "$1 ${time}" >>result.txt
}

pipefile=/tmp/$$.fifo
mkfifo $pipefile
exec 5<>$pipefile
rm -rf $pipefile

for ((i=0;i<50;i++))
do
 echo
done>&5

while read domain
do
 read<&5
 (main $domain && echo>&5)&
done <$1
wait
exec 5>&-

原文地址:https://www.cnblogs.com/chongchong88/p/ping_delay.html