File descriptor redirection with echo
1 answer
It's about the order when you do the redirect. When bash sees multiple redirects, it processes them from left to right.
The first stdout redirect redirects to the current value of stderr (tty). When stderr changes to / dev / null, stdout is still written to the previous output of stderrs (tty).
Change the location on these and it will work.
echo 'foo' 2>/dev/null 1>&2
See http://www.catonmat.net/blog/bash-one-liners-explained-part-three/ for details
+4
source to share