next up previous
Next: Other Useful C Shell Up: Standard Input and Output Previous: Redirecting Standard Input

Standard Output

Standart output is the destination for information from a command. This is assumed to be the terminal display unless output is redirected or piped to a file or another command.

To redirect the standard output from a command use the $>$ (greater than) symbol followed by the name of the output file. If the file that you redirect standard output to does not already exist it will be created.
For example:

grep Smith /etc/passwd $>$ popular

This redirects the standard output from the grep command so that it goes to the file popular. This file will contain all occurrences of the string Smith found in the /etc/passwd file.
Note: Redirecting standard output to a file that already exists overwrites its contents with the standard output.
You can append output to an existing file.

To append the standard output from a command to a file use $>>$ (two greater than) symbols followed by the file name. If the file does not exist it is created. For example:

cat part1 $>$ chapt2
cat part2 $>>$ chapt2

The first line creates a file called chapt2 with the same contents as part1. The second reads the contents of part2 and appends them to the file chapt2. The file chapt2 contains now the data from part1 followed by the data from part2.


next up previous
Next: Other Useful C Shell Up: Standard Input and Output Previous: Redirecting Standard Input
Instructional Support Group 2008-08-05