Gregg's MOTD

Tips & Tricks that I've Encountered Over the Years...

Prefix The Output of Any Command with a Timestamp

July 16, 2023 — Gregg Szumowski

You can prefix the output of every line with a timestamp by piping the command to the following sed command:

$ command | sed "s/^/\[date +ā€œ%Y%m%d%H%M%Sā€]/"

Tags: cli, sed, motd