I have seen this question: Shell redirection i/o order.
But I have another question. If this line fails to redirect stderr to file
:
ls -xy 2>&1 1>file
Then why this line can redirect stderr to grep
?
ls -xy 2>&1 | grep ls
I want to know how it is actually being run underneath.
It is said that 2>&1
redirects stderr to a copy of stdout. What does "a copy of stdout" mean? What is actually being copied?
The terminal registers itself (through the OS) for sending and receiving through the standard streams of the processes it creates, right? Does the other redirections go through the OS as well (I don't think so, as the terminal can handle this itself)?