Pipes

As I keep alluding to, Unix commands alone are powerful, but when you combine them together, you can accomplish complex tasks with ease. The way you combine Unix commands is through using pipes.

To create a pipe in Unix, you simply use a | character between the programs on the command line. A pipe is created by using the keystroke Shift+\. This creates a pipe, which looks like this: |. For those of you who are old MS-DOS users, yes, the command has generally the same meaning and is also called a pipe. The pipe, used at the shell prompt, will also help manipulate input. Let's look at an example of a pipe in use:

>cat newfile1.txt
Hello
How are you
Fine
>cat newfile1.txt | wc
      1       3      1

The word count command (WC) was used with cat and that's ...

Get SAMS Teach Yourself Unix in 10 Minutes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.