I’ve a pipline doing just
command1 | command2
So, stdout of command1 goes to command2 , while stderr of command1 go to the terminal (or wherever stdout of the shell is).
How can I pipe stderr of command1 to a third process (command3) while stdout is still going to command2 ?
Use another file descriptor
You can use up to 7 other file descriptors: from 3 to 9.
If you want more explanation, please ask, I can explain 😉
Test
output:
Example
Produce two log files:
1.
stderronly2.
stderrandstdoutIf
commandisecho "stdout"; echo "stderr" >&2then we can test it like that: