Prefix time to each line of bash command output

Posted by neildeadman on Super User See other posts from Super User or by neildeadman
Published on 2012-08-28T14:18:51Z Indexed on 2012/08/28 15:41 UTC
Read the original article Hit count: 292

Filed under:
|
|

I am running the top command to see details about specific processes. The output is piped to grep like so:

top -n 1 | grep jre

The output is usually around 4 lines, and I would like to prefix the current time to each line so it would be something like:

Before:

2772 deleteme  20   0  2832 1156  872 R  2.0  0.1   0:00.01 top  

After:

13:46 25-08-2012 2772 deleteme  20   0  2832 1156  872 R  2.0  0.1   0:00.01 top  

© Super User or respective owner

Related posts about bash

Related posts about grep