| (pipe)
What is | (pipe)?
| (pipe): Pipe — Send the output of one command as the input to the next. The pipe | connects commands. The output of the command on the left becomes the input of the command on the right. cat access.log | grep 404 | wc -l counts how many requests returned a 404.
Frequently asked questions about | (pipe)
How is | (pipe) used in practice?
This is the core idea of the Unix command line. Small tools each do one job well, and you combine them for the task at hand. You do not need a special program to count errors in a log; you chain three general ones.
What should you keep in mind with | (pipe)?
Two things are worth knowing. A pipe only passes normal output, not error messages, unless you add 2>&1. And in a script, a pipeline normally reports success if the last command succeeded, even when an earlier one failed. Add set -o pipefail at the top of Bash scripts so a failure anywhere in the chain is noticed.
At a glance
| Category | CLI commands |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |