Piping Input and Output

In general, you can think of each Unix command (ls, cd, and so on) as an individual program that Unix executes. For example, if you type cat /etc/mold at the prompt, Unix will display the contents of mold in the /etc directory. Each program requires input (in this example, cat, the program, takes the contents of /etc/mold as input) and produces output (i.e., the displayed results).

Frequently, you’ll want to run programs in sequence. For example, you could tell Unix to read your resume and then spell-check it. In doing this, you connect two commands together and have them run in sequence. This process, in which you connect the output of one program to the input of another, is called piping. Depending on what you want ...

Get Unix Third Edition: Visual Quickstart Guide 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.