Pipes WAS Re: [Sussex] linux command line

Mark Harrison Mark at ascentium.co.uk
Thu Jan 13 17:48:40 UTC 2005


----- Original Message ----- 
From: "John D." <big-john at dsl.pipex.com>
To: "LUG email list for the Sussex Counties" <sussex at mailman.lug.org.uk>
Sent: Thursday, January 13, 2005 3:28 PM
Subject: Re: [Sussex] linux command line


> On Thu, 2005-01-13 at 14:54 +0000, Geoffrey Teale wrote:
> <snip>
> >  (I'm sure you've already discovered the power of pipes).
>
> Ha Ha, yes top things pipes, get the water all the way from the road to
> my house boiler, bath and radiator! :-P
>
> Erm though seriously Geoff, I've read stuff on pipes, though I'm a bit,
> erm, vague? as to their actual use (like most CLI things!).

John,

Pipes are, in my view, just about the most powerful thing you can do with a
shell on linux.

The concept is a bit like separates hifi. Rather than have an all-in-one
tool that does everything, you have a bunch of different components and take
the output from one into the input of the next. In hifi you take the output
of your CD player, into the input of your preamp, then the output of your
preamp into the input of your power amp, then the output of your power amp
into the input of your speakers, and lo music appears.

In linux, you say that rather than having a whole bunch of complex command
options that overlap, such as a "sort the output" option on every tool, you
use pipes and simple commands.

So, for instance, if you want to see all the lines in a log file that
contain the word "error", and remove duplicates so you only see each error
once, you might use:

cat log.txt | grep "error" | sort -u

Hope this makes sense.

Regards,

Mark
Proudly using pipes since 1989 :-)





More information about the Sussex mailing list