Average ping time:
ping -w 4 -q www.duckduckgo.com | cut -d "/" -s -f5
Options:
-w time out 4 seconds -q quite mode -d delimiter -s skip line without delimiter -f No. of field - depends on your system - sometimes 5th, sometimes 4th
I personally use this method:
if [ $(ping -w 2 -q www.duckduckgo.com | cut -d "/" -s -f4 | cut -d "." -f1) -lt 20 ]; then echo "good response time" else echo "bad response time" fi
xerostomus
source share