The command is pretty simple:
echo 123 >/dev/null | cat
If you run in bash, it will show nothing. This is what I expected.
However, when I run this in zsh, it will show 123
. This is very surprising for me. Because it seems zsh pipes the stdout before redirection.
If I understood correctly, zsh can duplicate the stream for free (e.g by doing echo 123 2>&1 >&2 | cat
). But in bash we need to use tee
.
Just wonder if someone can explain the differences?
1