How do I timestamp every ping result?

bash, bsd, osx-lion, ping

Solution

On OS X you can simply use the --apple-time option:

ping -i 2 --apple-time www.apple.com

Produces results like:

10:09:55.691216 64 bytes from 72.246.225.209: icmp_seq=0 ttl=60 time=34.388 ms
10:09:57.687282 64 bytes from 72.246.225.209: icmp_seq=1 ttl=60 time=25.319 ms
10:09:59.729998 64 bytes from 72.246.225.209: icmp_seq=2 ttl=60 time=64.097 ms

Problem

Ping returns this by default: ``` 64 bytes from 203.173.50.132: icmp_seq=0 ttl=244 time=57.746 ms ``` Is there some way I can get it to add the timestamp? For example, ``` Mon 21 May 2012 15:15:37 EST | 64 bytes from 203.173.50.132: icmp_seq=0 ttl=244 time=57.746 ms ``` I'm on OS X v10.7 (Lion) which seems to have some BSD version of ping.

Original source