Many commands assume that input will come from stdin, and the output (and error messages) will go to stdout. There are many times when you will want to change these defaults and have a command take input from a file, or send output to a file. The shell's capability for redirection allows this. The C-shell supports six different command-line operators for redirection:
< Redirect stdin to a file. > Redirect stdout to a file.Redirect both stdout and stderr to a file. >> Append stdout to a file.
Append stdout and stderr to a file. << <word> Reads standard input until <word> is encountered,
The redirection commands will create a file if it doesn't already exist; if the file does exist, and the environment variable noclobber is not set, then it will be overwritten.
As an example, suppose you want to concatenate three files and send the resulting output to a fourth file:
cat file1 file2 file3 > file4
A command that normally expects input to come from stdin, and normally sends output to stdout can be redirected to read from an input file and write to an output file as follows: