Understanding stderr
The redirector operators for stderr
are 2>
and 2>>
. If you’re wondering why, it’s because of the file descriptor ID numbers that we looked at a few pages ago. The ID number for stderr
just happens to be 2
. As always, here’s the graphical representation:
Figure 4.3: How stderr works
If you run a command and something goes wrong, it will output an error message via stderr
. By default, this message will get sent to the computer screen. Also by default, stderr
messages get mixed in with stdout
messages. So, if your command outputs both good data and error messages, you’ll have to scroll through the output messages on your screen to separate the two. Fortunately, you can use redirectors to change that behavior. To show how this works, let’s take another look at the find
utility that we discussed in Chapter 2, Interpreting Commands.
If you’re logged on to a computer as a normal user and you use find...