使用curl測試連接某網站的速度
curl -o /dev/null -s -w "%{time_namelookup},%{time_connect}, \
%{time_starttransfer},%{time_total}" \
https://tw.yahoo.com && echo
#------------產生數字--------------------
0.004188,0.060702, 1.931382,8.039616$1表示第一個參數,使用到條件式 if.... else.... fi
#!/bin/bash
if [ $1 ]; then
url=$1
else
echo "請輸入url(exp:tw.yahoo.com)"
read url
fi
curl -o /dev/null -s -w \
"DNS 解析: %{time_namelookup}\n\
Client Request: %{time_connect}\n\
Server Respon: %{time_starttransfer}\n\
總花費時間: %{time_total}\n" \
"${url}"
Last updated