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.

1 Answer 1


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
  • Brilliant, this worked perfectly Commented Sep 12, 2015 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
    Commented Sep 19, 2015 at 7:08

You must log in to answer this question.

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