datefmt is a simple C program that formats unix timestamps in text streams
Let’s say we have some logs that contain unix timestamps:
$ cat logs.txt
EVENTS 1638499687 blahblah log1
EVENTS 1638499717 blahblah log2
We can pipe this log into datefmt to convert these timestamps into human-readable dates:
$ <logs.txt datefmt
EVENTS 2021-12-02 18:48 blahblah log1
EVENTS 2021-12-02 18:48 blahblah log2
Of course you can customize the format as well:
$ <logs.txt datefmt "DATE:'%m-%d %R'"
EVENTS DATE:'12-02 18:48' blahblah log1
EVENTS DATE:'12-02 18:48' blahblah log2
It’s as simple as that! It comes with some heuristics so that it doesn’t parse timestamp outside of a reasonable range.
Tarballs are available here, please feel free to package this for your linux distribution of choice!
Download and verify:
wget https://jb55.com/pgp.txt http://cdn.jb55.com/tarballs/datefmt/datefmt-0.2.2.tar.gz http://cdn.jb55.com/tarballs/datefmt/SHA256SUMS.txt http://cdn.jb55.com/tarballs/datefmt/SHA256SUMS.txt.asc
gpg --import < pgp.txt
sha256sum -c SHA256SUMS.txt
gpg --verify SHA256SUMS.txt.asc
Send patches to jb55@jb55.com