'bash cat pipe supposedly misbehaving
In the following, I have made echo to write to stderr; then it's piped to cat, which has both output streams connected to /dev/null.
$ echo something 1>&2 | cat 2>&1 >/dev/null
something
All in all, nothing should be printed. As it turns out, something still gets printed!
Can someone please explain what's happening here? TY.
Solution 1:[1]
As you write the output to stderr, it displays the output. If you would write it to stdout, it would not display the output.
This image from the wikipedia article about pipes explains it very well
For more information read the Wikipedia article about Pipelines in Linux.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Mime |

