I would like to issue a ping command and store the resulting ms value in a variable.
Sample output from a manual ping command:
Client5c:Source_Code user$ ping 8.8.8.8 -c 3
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: icmp_seq=0 ttl=54 time=84.222 ms
64 bytes from 8.8.8.8: icmp_seq=1 ttl=54 time=82.900 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=54 time=77.398 ms
My attempt from BASH from borrowed code snippets:
ping_val=`ping 8.8.8.8 -c 5 | grep "time= " | head -2 | tail -1 | awk {'print$2'} | cut -f1 -d:`
..which yields nothing.