3
3
I am running several tasks simultaneously at background.
command_a | tee > command_a.log &
command_b | tee > command_b.log &
If everything is fine, then messages will be saved to log files.
If something wrong, it will print errors on screen.
But command_a and command_b are quite similar, it’s hard to tell which error message is generated by which command.
Can I add prefix string to error messages, like:
command_a: error 123
command_b: error 456
command_a: error 256
command_a: error 555
command_b: error 333
For my understanding, 2> redirect all stderr, >() is redirect to a command, sed used to add prefix, after sed message become stdout, >&2 convert message back to stderr, finally save to log file. My understanding is correct? Thanks! @glenn jackman – Fisher – 2015-02-24T18:41:58.037
yes, except
>()
is called a "process substitution" – glenn jackman – 2015-02-24T18:42:43.373@Fisher you may want to accept an answer if it answers your question (that's the [so] way of saying "Thanks") – umläute – 2017-05-29T09:18:37.503