O'Reilly logo

SAMS Teach Yourself Unix in 10 Minutes by Robert Shimonski

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required