Author Topic: One for the Unix/bash/shell script experts  (Read 678 times)

Ben T

One for the Unix/bash/shell script experts
« on: 16 June, 2020, 09:46:28 pm »
Before I invent this particular wheel is there anything out there that does this:
If I have a process that outputs to stdout say

Hello world
I have done a long job
I have done another long job

What I want is another process that I can pipe that to its stdin , and it will output

00:00 Hello world
10:00 I have done a long job
20:00 I have done another long job

Know what I mean? Where the first bit is just the current time down to second level.
Just so I know when each line got written. Doesn't have to be bash/ shell, could be python or whatever. Main thing is it doesn't disrupt the primary process, (and it doesn't wait to the end of the primary process before writing anything obviously.)
I would ideally like to capture stdout and stderr but I can do that with 2>&1 can't I?

Kim

  • Timelord
    • Fediverse
Re: One for the Unix/bash/shell script experts
« Reply #1 on: 16 June, 2020, 09:58:13 pm »
'ts' from the moreutils package does exactly that.

Ben T

Re: One for the Unix/bash/shell script experts
« Reply #2 on: 17 June, 2020, 09:24:13 am »
'ts' from the moreutils package does exactly that.
cheers, thought there would be something.  :thumbsup: