Many operating systems have a command line that supports piped input and output.
Programs that consume input from the standard input, stdin, can be executed such that the input is redirected from a file instead of from the keyboard.
Programs that produce output to the standard output, stdout, can be executed such that the output is redirected to a file instead of to the screen.
There is also a standard error, stderr, output pipe.
The following are standard redirection characters.
The standard input redirection is "<" (less-than sign).
The standard output redirection is ">" (greater-than sign).
The standard output append redirection is ">>".
The standard error redirection is "2>".
In Linux (and Windows) the vertical bar character "
|" is used to take the output of one program and use it for input to the next program (on the command line).
Note the use of the redirection character "
>" to output to a file.
Likewise, programs that take input from the standard input can have input redirected from a file by using the redirection character "
<".
The Python executable supports redirection to both the standard output and standard error pipes from the command line. Here is the general form of the command.
python.exe program-text-file > output-text-file 2> error-text-file
For historical reasons, stream 2, as in redirection using "
2>" is the standard output.