Foundations Updated 2026-09 View as Markdown

Pipelines

Pipelines, often called pipes, is a way to chain commands and connect output from one command to the input of the next.

Pipelines, often called pipes, is a way to chain commands and connect output from one command to the input of the next. A pipeline is represented by the pipe character: |. It’s particularly handy when a complex or long input is required for a command.

shell
command1 | command2

By default pipelines redirects only the standard output, if you want to include the standard error you need to use the form |& which is a short hand for 2>&1 |.

Example:#

Imagine you quickly want to know the number of entries in a directory, you can use a pipe to redirect the output of the ls command to the wc command with option -l.

shell
ls / | wc -l

Then you want to see only the first 10 results

shell
ls / | head

Note: head outputs the first 10 lines by default, use option -n to change this behavior

Exercise

Try it

run this one locally

Expected output

4

Get the Bash agent pack

A battle-tested AGENTS.md, the review checklist, and the failure-mode cheat sheet for Bash. One email, then occasional updates when the tooling shifts. No course pitch.

Unsubscribe in one click. We never sell the list. Or just take the AGENTS.md now — no email needed.