LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Command errors vs. bash errors (https://www.linuxquestions.org/questions/linux-newbie-8/command-errors-vs-bash-errors-914760/)

a_d1234 11-21-2011 02:47 PM

Command errors vs. bash errors
 
Hi guys.
What are the differences between these two kinds of errors? (command error vs. bash error)
I'm an absolute newbie, so any help will be appreciated.


$ wc -l /etc/password
wc: /etc/password: No such file or directory
$ wc -l < /etc/password
bash: /etc/password: No such file or directory

kbp 11-21-2011 03:49 PM

None really .. the error is displayed by the shell and shows the process that reported the error.

In the first case the process was 'wc' as it attempted to open the file.

In the second case it was 'bash' as it tried to open the file and feed it to 'wc' as input.

David the H. 11-21-2011 03:53 PM

bash is, in the end, just another command. In the first line, the wc command is giving you an error, and in the second, it's the shell.

The reason for the difference is that in the first case bash launches wc with the filename passed to it as an argument. wc then looks for the filename that it was given, can't find it, and complains.

In the second case, you're using a redirection, which is a function of the shell. Now it's bash that's looking for the file, so that it can open it and send the contents into wc, and complaining when it can't be found.


All times are GMT -5. The time now is 02:13 PM.