#1100002 Recognise unix time on stdin for ts in moreutils

Package:
moreutils
Source:
moreutils
Description:
additional Unix utilities
Submitter:
Steven Maddox
Date:
2025-03-10 07:33:02 UTC
Severity:
normal
#1100002#5
Date:
2025-03-10 07:12:58 UTC
From:
To:
Hi,

Unless I'm mistaken there doesn't seem to be a way to make 'ts'
recognise unix time on stdin for conversion.

This would be really useful to convert unix time to something human...

Example 1...
   ping -D 8.8.8.8 | ts -r '%a %d %H:%M:%S'
Output without ts...
   [1741590256.689051] 64 bytes from 8.8.8.8: icmp_seq=1 ttl=115 time=11.3 m
Output with ts... (if it had this feature)
   Mon 10 07:04:17 64 bytes from 8.8.8.8: icmp_seq=1 ttl=115 time=11.3 ms

This would be more precise than doing this without -D and -r, and would
actually convert the time rather than append.

Example 2...
   dmesg | ts -r '%a %d %H:%M:%S'
Output without ts...
   [261669.940924] usb 3-3: USB disconnect, device number 9
Output with ts... (if it had this feature)
   Sun 04 00:41:09 usb 3-3: USB disconnect, device number 9

I am aware that dmesg has -T now, but it didn't always have this...
perhaps some other utilities haven't had that treatment yet too.

Also lots of log files you might want to pipe through ts using cat are
prefixed with unix time timestamps in the same way.

Any thoughts?