CPSC 231: Note
Redirection

Sometimes when a great deal of input is required by a program it isn't practical to retype all the input needed each time that the program is run e.g., you wouldn't want to re-answer all 100 questions in a survey program each time you wanted to test it. That's where redirection of input (and output) come into play. Look at the sample program [survey.py] as an example. Although it only requires 2 inputs it's easy to envision programs that require many more. Redirection can be used to automate the input process by testing specific test cases. There are two input files for this program [in1.txt] [in2.txt]. You can use redirection so that the text in these two files gets 'redirected' as input for the survey program "python survey < in1.txt".

Redirection can also be used so that the output of a program gets "redirected" from the standard output into a file. In the above example we could have the print statements from the program get saved to an output file (in this example it's out1.txt) "python survey < in1.txt > out1.txt" which would produce this file [out1.txt]. Common reasons why you might want to redirect output include:  1) there is too much information to display on one screen (e.g., try navigating to "/home/uga" and then type 'ls')  2) you want to retain the program output for later. For those who are interested additional details on how redirection work Wikipedia has a decent description of redirection.