Lesson 6.5: Pipes
The | operator: connecting stdout of one command to stdin of the next, the Unix philosophy of small tools, filters, building a pipeline step by step on a web server log, and what pipes do with errors.
16 min
You will learn to
- Explain what | connects
- Build a pipeline one step at a time
- Use common filters (grep, cut, sort, uniq, head, wc) in a pipeline
- Explain why errors don't go through a pipe
Key terms
- Pipe |
- Connects the stdout of the command on its left to the stdin of the command on its right. Both run at the same time; data flows as it's produced.
- Pipeline
- Several commands joined by pipes.
- Filter
- A program that reads text on stdin, changes or selects it, and writes the result on stdout. grep, sort, uniq, cut, head, tail, wc, tr, awk and sed are all filters.
- Unix philosophy
- Write programs that do one thing and do it well, that work together, and that handle text streams as a universal interface.
- cut
- Cuts fields out of each line: -d sets the delimiter, -f picks fields.
← Redirecting input and output · All lessons · Command history →