jack jack - 4 months ago 25
Linux Question

extract average time from ping -c

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

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
Comments