0

I could not find similar question, so decided to post it

I have a long running job (*nix environment):

program > job.out

which is running over days and prints output in chunks. Can I instead of "job.out" have a script (maybe Perl?) that will modify chunked output (for example prepend a timestamp) and write it to job.out.

oers
  • 18,436
  • 13
  • 66
  • 75
af3
  • 13
  • 2

2 Answers2

2
program | perl -ne 'printf("%s %s",time,$_)' > job.out
Alex Howansky
  • 50,515
  • 8
  • 78
  • 98
1

Yes. You can. Just do it like this:

program | perl myperlscript.pl > job.out

In the perl script, just accept input from stdin and write to stdout.

Jonathan M
  • 17,145
  • 9
  • 58
  • 91
  • 3
    *"However, the perl script will not start until program is complete."* - not true, the shell will start both of the piped processes at the same time. – Blagovest Buyukliev Nov 18 '11 at 15:30