Get a ping result with date and time

November 2016



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 :

This document entitled « Get a ping result with date and time » from CCM (ccm.net) is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.