Posts Tagged ‘pipes’

Pipes, Redirection and Chaining

Wednesday, March 12th, 2008

Please read about Standard-output and Standard-input first.

Even though most people consider the command-line a thing of the past, there are some really interesting things you can do with the terminal that enables it to be more powerful than the gui interface.

Two advantages are the use of pipes, chaining, and redirection. With pipes, chaining, and redirection, you can “chain” multiple programs and functions to become extremely powerful commands. Most programs on the command-line accept different modes of operation. Many can read and write to files for data, and most can accept standard input or output. This means that you can direct the output of one program as input to another program. You can then take the output of the second program and redirect it as input to yet another program, or redirect the output to a file.

In fact, most programs have two modes of output: standard output (stdout for short) and standard error (stderr). These are both different streams of output that are distinct from each other, which can allow you to redirect the stderr of a program to the same “stream” as the standard input (stdin), or redirect them to different places.

(more…)