next up previous
Next: awk Up: intro_Unix Previous: Quick Summary of Important

Using I/O Streams

When we say a command ``prints'' a value we typically mean that it displays the value on your terminal screen. What's really happening is that the result of the command is being sent to ``standard output'' (stdout), which by default is your screen. Similarly, ``standard input'' (stdin) is by default your keyboard. Data moving from the standard input to the standard output is an example of an I/O stream. It is possible to divert such streams to a certain extent. The following table summarizes the most common stream controls used in the csh environment with some examples:


Operator Function Example Description
< redirect stdin mail dcr < myfile mail dcr the contents of myfile
> redirect stdout myprog > log write output from myprog to log
» append stdout myprog » log append output from myprog to log
« word redirect stdin until word myprog « STOP send next lines to myprog until STOP
| pipe stdout to stdin echo test | lpr send phrase ``test'' to printer


There are also modifiers like >& (to redirect both stdout and ``standard error'' (stderr), the diagnostic stream) and >! (to ``clobber'' an existing output file without confirmation).


next up previous
Next: awk Up: intro_Unix Previous: Quick Summary of Important
Massimo Ricotti 2009-01-26