Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ttlequals0/ebf6a9571d9d1dc6b0f9283ad5fae646 to your computer and use it in GitHub Desktop.
Save ttlequals0/ebf6a9571d9d1dc6b0f9283ad5fae646 to your computer and use it in GitHub Desktop.
Ping with timestamps written to file with newest entry at top
echo -e "\n" > file ; ping 127.0.0.1 | while read l; do newline=$(echo "[$(date '+%H:%M:%S')] $l") ;sed -i "1s/^/$newline\n/" file ; done
[20:31:06] 64 bytes from 127.0.0.1: icmp_seq=7 ttl=64 time=0.075 ms
[20:31:05] 64 bytes from 127.0.0.1: icmp_seq=6 ttl=64 time=0.079 ms
[20:31:04] 64 bytes from 127.0.0.1: icmp_seq=5 ttl=64 time=0.207 ms
[20:31:03] 64 bytes from 127.0.0.1: icmp_seq=4 ttl=64 time=0.077 ms
[20:31:02] 64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.075 ms
[20:31:01] 64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.108 ms
[20:31:00] 64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.149 ms
[20:30:59] 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.070 ms
[20:30:59] PING 127.0.0.1 (127.0.0.1): 56 data bytes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment