I want to extract from the command ping -c 4 www.stackoverflow.com | tail -1| awk '{print $4}'
the average time.
107.921/108.929/110.394/0.905 ms
Output should be: 108.929
In gaming, any amounts below a ping of 20 ms are considered exceptional and “low ping,” amounts between 50 ms and 100 ms range from very good to average, while a ping of 150 ms or more is less desirable and deemed “high ping.”
Ping (latency is the technically more correct term) means the time it takes for a small data set to be transmitted from your device to a server on the Internet and back to your device again. The ping time is measured in milliseconds (ms).
One way is to just add a cut to what you have there.
ping -c 4 www.stackoverflow.com | tail -1| awk '{print $4}' | cut -d '/' -f 2
ping -c 4 www.stackoverflow.com | tail -1| awk -F '/' '{print $5}'
would work fine.
"-F" option is used to specify the field separator.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With