Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Add timestamps to Unix commands that run at intervals' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Add timestamps to Unix commands that run at intervals
Authored by: kps on Jan 22, '10 11:07:16AM
That doesn't do the right thing; it prefixes every line with the time the command was started. Try
awk '{system("echo -n \"`date +%T` \""); print $0}'
Or using just the shell:
while read x; do echo "$(date +%T) $x"; done
More likely you'd make one of these a script, shell function, or alias, so that you could apply it easily to any output.

[ Reply to This | # ]
Add timestamps to Unix commands that run at intervals
Authored by: ctierney on Jan 23, '10 04:24:45AM

Oh! You're right. I was paying attention to my test output. Thanks.



[ Reply to This | # ]