Get a ping result with date and time

March 2017



Issue


How to get a ping results with the date and time?

Solution


Try this:
$ ping -c 4 www.google.com | awk '/64/ {"date" | getline date ; print $0, "\t\t" date ; close("date")}'


Result:
64 bytes from mil01s16-in-f20.1e100.net (173.194.35.20): icmp_seq=1 ttl=56 time=20.1 ms Thu Mar 22 10:45:38 CET 2012
64 bytes from mil01s16-in-f20.1e100.net (173.194.35.20): icmp_seq=2 ttl=56 time=19.7 ms Thu Mar 22 10:45:39 CET 2012
64 bytes from mil01s16-in-f20.1e100.net (173.194.35.20): icmp_seq=3 ttl=56 time=19.7 ms Thu Mar 22 10:45:40 CET 2012
64 bytes from mil01s16-in-f20.1e100.net (173.194.35.20): icmp_seq=4 ttl=56 time=18.8 ms Thu Mar 22 10:45:41 CET 2012
$


Thanks to dubcek for this tip.

Related


Published by aakai1056.
This document, titled "Get a ping result with date and time," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (ccm.net).