Chapter 5 of 10All chapters
Chapter 5 of 10
Pipes and redirection
Joining small tools together.
The plumbing
A pipe sends one command's output into the next command's input. A single angle bracket writes output to a file and two appends to it.
- grep filters lines, sort orders them, uniq collapses repeats, wc counts.
- cat access.log | grep 404 | wc -l counts the not found responses.
Streams
Every program has standard input, standard output and standard error. Errors are separate so they still reach you when output is redirected, and 2> captures them on their own.