Go to the previous, next section.
Most commands get their input from standard input, which is usually the terminal, and send their output to standard output, which is also usually the terminal. Errors go to standard error. I/O redirection and piping allow you to specify otherwise.
I/O redirection lets you tell a command to read its input from a file, write its output to a file, or both. Piping allows you to tell a command to read its input from another command's output or even to read its input from the output of a string of several commands.
For example, let's assume you want to compute the wages earned by all professors in the College of Business during the past five years. The program you are using will read in data one line at a time. You could process the information line by line, typing in each piece of data each time the program asked for it, or you could do it much more quickly by using input output redirection. Your command line would look something like this:
program < datafile > resultsfile
With input output redirection, you would simply need to create a `datafile', and then look at the `resultsfile'.
If your data needs to be processed by several programs, you can use piping to save quite a bit of time.
cat datafile | program1 | program2 | program3 > resultsfile
In this case, data is taken from `datafile', processed by
program1
which passes it on to program2
which process it
farther and passes it on to program3
which processes it and
placed it into resultsfile.
Go to the previous, next section.