up previous next contents
Next: Creating Pipelines Up: Combining UNIX Commands Previous: Standard Error Symbols   Contents

Redirecting the standard error is also best shown by example:

Example 3-4: Standard Error Redirection Examples.

When you issue the command:

    ls -l z*

in a directory where there are no files that begin with the letter "z", you will get an error from your shell. This error is written from your shell to the device known as "standard error". The error will look something like this:

UX:ls: ERROR:  Cannot access z\*\: No such file or directory.

There are times when you may not want to have this error displayed on your screen. If that is the case, then you will want to redirect the standard error output so that it is not displayed on the screen. (Remember, the monitor is only the default device for the standard error and can be easily changed).

If you do not want to see the standard error from a command, and you are using the Bourne shell, you will type:

    ls -l z*  2>  /dev/null

This command tells your Bourne shell that if any errors do occur, redirect the error so that it is sent to "/dev/null". This device (/dev/null) is often referred to as the "bit bucket", because any time a user is getting output that they don't want, they send it here. It's like a garbage can for your unwanted bits.


up previous next contents
Next: Creating Pipelines Up: Combining UNIX Commands Previous: Standard Error Symbols   Contents