Send Close Add comments: (status displays here)
Got it!  This site "www.robinsnyder.com" uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.  Note: This appears on each machine/browser from which this site is accessed.
Pipes and redirection
by RS  admin@robinsnyder.com : 1024 x 640


1. Command line pipes
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.

2. Standard input and the keyboard
Whenever typing input into a program, the following keys simulate the end of file for stdin.

3. Redirection characters
The following are standard redirection characters. 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.

4. End of page

by RS  admin@robinsnyder.com : 1024 x 640