I read that redirections are processed left to right. So in this example
command 2>&1 | less
One would think that fd 2 is directed to fd 1 first and then fd 1 is sent to pipe. So fd 1 and 2 point to separate places.
But actually here fd 1 and 2 both point to the pipe, because for some reason fd 1 is sent to pipe first and then fd 2 is sent to fd 1. Why are redirections processed right to left in this case?
The pipe is not a redirection, so in fact redirections (of which there is only one in your example) are being processed the way you think. The pipe is a separate thing at the end.
The reason is that pipes aren't the same as redirections. A redirect affects the one command, while a pipe joins two commands.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With