node app.js > out.log 2>&1
node app.js 2>&1 > out.log
The first sends stdout and stderr to
out.log; the second sends stdout to out.log while stderr still goes to the terminalThe shell applies redirections from left to right. 2>&1 makes fd 2 (stderr) a copy of wherever fd 1 (stdout) points at that moment.
In the first command, stdout already points at the file. So stderr follows it to the file too.
In the second command, stdout still points at the terminal when stderr copies it. Only after that does stdout move to the file. So stderr stays on the terminal.
This is why "They are identical; the order of redirections doesn't matter" is wrong: the order changes the result.
Read more