----- Original Message -----=20
From: Thomas Bauer=20
Sent: Thursday, June 22, 2000 10:45 AM
Subject: pipes and stuff
I'm new to the group, and I don't know what you discussed in the past, =
but I would love to have an explaination about those different kid of =
pipes and so on ( > < | >> 2| )
Also please help me with thos ` =B4 and so on ..
From: William Shotts <bshotts@cl...> - 2000-06-26 17:50:50
On Mon, 26 Jun 2000, Thomas Bauer wrote:
> I'm new to the group, and I don't know what you discussed in the past, but
> I would love to have an explaination about those different kid of pipes
> and so on ( > < | >> 2| )
> Also please help me with thos ` ´ and so on ..
> thank you!
Glad to have you Pauli!
You have asked about an excellent topic. Since I have been working on
tutorials for LinuxCommand.org, I guess it is my duty to answer first.
The topic you have chosen is called "I/O redirection". I/O stands for
On the Linux command line (like Unix), many commands are designed to
input and output streams of data. For example, when you type "ls", the ls
program figures out the contents of the current working directory and
outputs it to the screen. But actually it produces a stream of data and
sends it to a facility called "standard output". Standard output (stdout)
will end up on the display by default unless you tell it something else.
I/O redirection allows us to take these streams of data and redirect them.
For example, using ls once again, we can say:
ls > file.txt
This will redirect the standard output of the ls program and store it in a
file called "file.txt".
Each time you run the above command, the contents of file.txt is
overwritten with the output from ls. If, however, you wanted to append
the output to an existing copy of file.txt you would say:
ls >> file.txt
Besides standard output, many programs feature standard input which
can also be redirected. For example, let's say that you have captured the
output of ls into the file file.txt, you could format that file with the
"pr" program like so:
pr < file.txt
This command will cause the pr program to execute and take its input from
file.txt rather than from the keyboard which is the default source of
Knowing that programs can take take input from standard input and can
output to standard output, it is possible to connect programs together
using a technique called piping. To simplfy the above example you could
ls | pr
The "|" character is called the piping symbol. This means take the output
of the first program and feed it into the input of the second. One of my
favorite uses of this technique is with the "less" program. Say you want
to look at a long directory listing (like /etc). You could do this for
ls -l /etc | less
||||| William Shotts, Jr. (bshotts@...)
||||| http://www.clark.net/pub/bshotts/ (Updated 04/13/2000)
||||| Be a Linux Commander! Follow me to http://linuxcommand.org