Why does this command show error message despite using 2> symbol?
cat < foo 2>bar bash : cannot open foo : No such file or directory
This will run
As @Casey notes, putting the command in a subshell works:
However, the subshell is not necessary. A simple list works just as well:
You don't even need the list if you observe that the order in which redirects are done makes a difference:
My conclusion is that what matters is bash's processing order: the issue is whether stderr has been redirected before or after the moment when bash discovers that the redirect of stdin fails. Thus, there is no output from the last example above because bash first redirects stderr and then tries to open foo for stdin.