i am wondering how exactly you would get a simple integer result instead of all the miscellaneous information such as the packet size, transmission number and target.

To elaborate: I would prefer the output to look like:


A single integer response, similar to how the syntax: ping -c 1 google.com returns a single result, however i would prefer the method to omit the detailed ping report and only displays a single number.

Thanks in advance.


Try this:

ping -c 1 google.com | grep "time=" | sed -E "s/(.*)time=([.0-9]+) ms/\2/"

If you want to get an minimal value for some number of requests use:

ping -q -c 5 google.com | tail -1 | cut -d "=" -f 2 | cut -d "/" -f 1

Replace 1 in -f 1 with:

  • 2 for average
  • 3 for maximum
| improve this answer | |
  • Brilliant, this worked perfectly – user4493605 Sep 12 '15 at 5:50
  • 1
    Or ping -c 1 google.com | sed -nE "/time=/s/(.*)time=([.0-9]+) ms/\2/p" if you want to keep it short :-) – nohillside Sep 19 '15 at 7:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .