Suppose that you redirect, in bash, the standard output of a command cmd to a file named f.out, and the standard error to f.err, using tee to preserve console printing:
cmd 1> >(tee f.out) 2> >(tee f.err)
Then f.out contains the output as well as the error (at least on my system).
Now, if you change the order of redirections:
cmd 2> >(tee f.err) 1> >(tee f.out)
f.out only contains the output (and f.err only contains the error in both cases).
So my question is double: how stderr can be redirected to f.out, and why does the order of redirections impact the result?
Note that if you don't use tee, but for example cat, like this:
cmd 1> >(cat>f.out) 2> >(cat>f.err)
you don't have this issue, and the order of redirections doesn't matter, as expected, and as it would be the case without process substitution (cmd 1>f.out 2>f.err).
tee f.err’s stdout andtee f.out’s stdin, viacmd's stdout. It seems that I confused "different processes" and "independent processes". Thank you for your response anyway!