Reputation: 1
How can I change my current Ping timestamps to include milliseconds? Currently it gives me date which only has seconds fine-grained.
ping google.com | while read pong; do echo " $pong @$(date)"; done
If note that the answers should be executable on shell as I am running it on a phone using ADB.
Upvotes: 0
Views: 2059
Reputation: 15204
If you're happy with Nanoseconds ... (milliseconds would require some extra maths that would impact on execution time) this would work:
ping google.com | while read pong; do echo " $pong @$(date '+%Y%m%d%H%M%S.%N')"; done
And dissecting the format string we threw at date
%Y = 4-digit year
%m = month
%d = day
%H = hour
%M = minute
%S = seconds
%N = nanoseconds
For details:
man date
Upvotes: 2