Chain commands with pipes
Connect commands with |
⏱ Est. ~4 min
01 · Read
The terminal's real power comes from combining commands. A pipe (|) takes the output of one command and feeds it as input into the next.
💡 Picture thisImagine a production line — each station does one task, then hands the result to the next.
Key points
- | (pipe) connects two commands
- The output of the left command becomes the input of the right command
- You can chain many pipes: cmd1 | cmd2 | cmd3
02 · Terminal exercise
This server.log file has 100 entries. Let's start by finding all the errors.
(This section is interactive — please enable JavaScript.)
03 · Terminal exercise
| (pipe) sends the output of one command to another. Use it to see only the first 3 errors.
(This section is interactive — please enable JavaScript.)
04 · Terminal exercise
Chain three commands together: read the file, filter for warnings, see only the last 5.
(This section is interactive — please enable JavaScript.)
05 · Quiz
What does the pipe | symbol do?
- Save output to a file
- Run two commands at the same time
- Back up output
- Feed one command's output into the next command as input
Other lessons in this chapter
⚠ The full interactive experience needs JavaScript. Please enable it and reload.
※ This is an independent Traditional Chinese teaching project — not an official Anthropic product. Claude™ is a trademark of Anthropic, PBC.