# Pipes and man Pages

> How to read the built-in help for any command with man. How the | sign joins small commands into one line that does a bigger job.

**Course:** [Linux Command Line](https://learn.benibix.com/learn/infrastructure-linux)  
**Time:** 10 min

**After this lesson you can:**

- Open and leave a man page
- Join two commands with a pipe
- Build a short chain to answer a question

## How to find help and join commands

Every Linux command comes with a help page, called a man page. Type man and the command's name, such as man ls. The page says what the command does, how to type it and what each option means. Press the space bar to go down a page and q to leave. The help is on the machine, so it works with no internet.

A man page has the same parts every time. The name and one line on what it does. The synopsis, which shows how to type it. The description. Then a list of options. Square brackets in the synopsis mark parts you may leave out.

Linux commands are small on purpose. Each one does one job. ls lists files. sort puts lines in order. grep keeps only the lines that hold a word. wc counts lines. On their own they are plain. Joined together they do a lot.

The pipe is how you join them. It is the | sign, typed between two commands. It takes everything the first one prints and hands it to the second one, instead of to the screen. You can chain as many as you like, each one feeding the next.

So ls | wc -l lists the files and counts the lines, which tells you how many files there are. A pipe works like a kitchen line. One cook chops, the next fries, and the last one plates. No single cook does the whole dish.

Many commands can also read a file instead of a pipe. grep error app.log reads the file directly. Either way works, and you will see both in guides.

A common mistake is to search the web before reading the man page. A web answer may be for a different version, or for macOS, where some options differ. The man page on the machine always matches the command you are about to run.

```console
$ printf "pear\napple\nfig\n" | sort
apple
fig
pear
```
printf prints three words. The pipe hands them to sort, which prints them in order.

![Two command boxes joined by a pipe sign. The first, printf, prints three words, pear, apple and fig, which flow through the pipe into sort. Sort passes apple, fig and pear in order to the screen at the end.](https://learn.benibix.com/diagrams/inf3-pipe.svg)

### Example: Lucy counts the errors in a log

Lucy's app wrote a log of 50,000 lines overnight. She wants to know how many lines say error.

She types grep error app.log | wc -l. grep keeps the 212 lines that hold the word, and wc counts them. It takes under a second.

**Words in this lesson:** [man Page](https://learn.benibix.com/term/infrastructure/man-page), [Pipe (|)](https://learn.benibix.com/term/infrastructure/pipe)

**Question:** What does the | sign do between two commands?

**Answer:** It hands what the first command prints to the second one. The pipe takes all that the first command prints. It feeds it to the second one, not to the screen.

---

Source: https://learn.benibix.com/learn/infrastructure-linux/pipes-and-man-pages
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-19
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
