CONCEPT: Every program you run from the shell opens three files: Standard input, standard output, and standard error. These files provide the primary means of communications between the programs, and exist for as long as the process runs.
The standard input file provides a way to send data to a process. As a default, the standard input is read from the terminal keyboard.
The standard output provides a means for the program to output data. As a default, the standard output goes to the terminal display screen.
The standard error is where the program reports any errors encountered during execution. By default, the standard error goes to the terminal display.
CONCEPT: A program can be told where to look for input and where to send output, using input/output redirection. UNIX uses the "less-than" and "greater-than" special characters, < and >, to signify input and output redirection, respectively.
EXAMPLE:Use standard input redirection to send the contents of the file /.cshrc to the more command:
Many UNIX commands that will accept a file name as a command line argument, will also accept input from standard input if no file is given on the command line.
EXAMPLE: To see the first ten lines of the /.cshrc file, the command:
EXAMPLE: Type the command
Use two "greater-than" signs to append to an existing file. For example:
EXAMPLE: List the contents of the /tmp directory and put it in a file called myls. Then, list the contents of the /etc directory, and append it to the file myls:
EXAMPLE: Sort the /.cshrc file, place the results in a file called tempfile, and trap any errors in a file called err with the command: