Pipes WAS Re: [Sussex] linux command line

Thomas Adam thomas at edulinux.homeunix.org
Thu Jan 13 18:17:18 UTC 2005


On Thu, Jan 13, 2005 at 05:48:32PM -0000, Mark Harrison wrote:
> Pipes are, in my view, just about the most powerful thing you can do
> with a shell on linux.

They're _one_ of a number of features that the shell has to offer (I
assume we're talking about bash -- ksh and zsh have some other subsets
of features bash does not).

As Mark mentions the idea of a pipe is to take the output of one
command, and feed it as input to another:

foo | bar

Whenever you see a pipe symbol in a shell script (or on the command
line), you should be aware that the pipe indicates a fork() (no, for
those of you wondering, it does not necessitate an exec() -- only
external commands do). 

What does this mean? This means that there is an intermediary "pipe"
connecting the two processes together so that they can talk to each
other.  Of course, you might be wondering which side of the pipe
communicates with which.  In older shells, the commands on the left of
the pipe are performed by the child process, while the parent performs
that on the right.  In newer shells (bash) the opposite is true,
although in *both* casesthe child executes the commands and exits.
Meanwhile the parent executes the other set of commands and continues to
live.

I could go on for hours about this, but I shan't bore you further.

-- Thomas Adam

-- 
I know nothing, and understand even less.




More information about the Sussex mailing list