When I use my shell’s redirection operator to provide a (non-existent)
filename to the grep command, the error message about that file not
existing is displayed by my shell. But when I provide that same filename
as an argument to the grep command, the corresponding error message is
displayed by the grep command itself. Why is that?
Here’s a demonstration of what I’m talking about. When I run the command:
$ grep 'root' /etc/passw
I get the following error message:
grep: /etc/passw: No such file or directory
But when I run the command this way with shell redirection:
$ grep 'root' < /etc/passw
I instead get the following error message:
bash: /etc/passw: No such file or directory
What is the difference between these two methods of specifying the input filename, and is there any significance in having them behave this way?