Comment goes here
You should log in and post some comments! The link is up there in the toolbar. Go nuts!
 

Using 'Pipes' in Linux

« Back to Basics Articles

Beginners Level Course: Using 'Pipes' in Linux


In this lesson, we're going to do a little plumbing. Plumbing with a computer? Well, Linux is so flexible that it even allows you to do plumbing with it. Well.... actually, it's just a little witticism of mine because the command we're going to learn in this lesson is called 'pipe', and plumbers work with pipes. To use the pipe command, you don't type: pipe. You press the '|' key. The location will vary on keyboards from country to country. This symbol is like two vertical slashes, one on top of the other.

This is the first time that we're going to see a command that's meant to be used with other commands. That means that the pipe will separate two commands so that they will be done one after the other. Let's try some plumbing.


For example, if you looked at the contents of your /proc directory with:
ls -l /proc

it would be too big to fit in one screen. So if we typed
ls -l /proc | more

you could scroll down with the ENTER key and see it all.

Actually, ls -l /proc | less is a better solution because you can scroll up and down with the arrow keys. Remember that in a previous lesson we said: "Less is more than more".

You're probably going to end up using this a lot. You're personal directory in /home will fill up and pretty soon 'ls -l' will overflow in your terminal or x-terminal window.

There's a little short cut if you've forgotten to use the pipe. You can also scroll up and down in a terminal with the SHIFT-PAGE UP / SHIFT-PAGE DOWN keys.