extract average time from ping -c

creativeDev picture creativeDev · Mar 9, 2012 · Viewed 29.5k times · Source

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

Answer

Buggabill picture Buggabill · Mar 9, 2012

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