O'Reilly logo

Practical UNIX by Steve Moritsugu - DTR Business Systems

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Redirecting Standard I/O

Most UNIX commands invoke a special routine called standard output (or stdout) to display information. They invoke a different routine called standard error (or stderr) to display any error messages. There is a similar routine to get input called standard input (or stdin).

In the following example, mp0094 could not be listed, so an error message went to standard error (stderr):

dtr> ls mp0094 mp0095
ls: mp0094 not found: No such file or directory (error 2)
mp0095
dtr>

Here, mp0095 was found and listed to standard output (stdout). Using the standard error routine for error messages allows the shell to redirect the errors from the screen to a file, as in the following example:

dtr> ls mp0094 mp0095 2> myerrors mp0095 dtr> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required