Get a ping result with date and time

Ask a question


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.
Jean-François Pillou

CCM is a leading international tech website. Our content is written in collaboration with IT experts, under the direction of Jeff Pillou, founder of CCM.net. CCM reaches more than 50 million unique visitors per month and is available in 11 languages.

Learn more about the CCM team