previous contents up next

Unix for Advanced Users

6. Manipulating Files

6.1. Creating Files

6.1.4. I/O redirection

In the Unix shell, the standard output of a command always goes to a file--that is, every command has access to a file object to which it sends its output. Normally, that file is the device file for the terminal on which the command is running, so that the output appears on the screen. However, it is possible to redirect that output to any other file. For instance, you could create a file with ls -al > listing. You could then append more listed filenames with ls -al other_directory/ >> listing.

All commands have access to a second file called standard error. As its name implies, it is reserved for error messages. The shells provide resources for redirecting standard error as well.

Both Bourne- and csh-family shells provide facilities to redirect standard output and standard error. A complete treatment of redirection is available in the shell section, as are the specifics of redirection for Bourne-family shells and for csh-family shells.

previous contents up next