Sample Header Ad - 728x90

Prepending a timestamp to each line of output from a command

393 votes
12 answers
248433 views
I wish to prepend a timestamp to each line of output from a command. For example: foo bar baz would become [2011-12-13 12:20:38] foo [2011-12-13 12:21:32] bar [2011-12-13 12:22:20] baz ...where the time being prefixed is the time at which the line was printed. How can I achieve this?
Asked by anon
Dec 13, 2011, 11:49 AM
Last activity: Jun 21, 2025, 01:25 PM