Imagine an assembly line. One robot catches the fish, the next one cleans it, the next one cans it. In Linux, the | symbol joins commands into an assembly line.
🐧 Tux tells a storyWhy this is a superpower
Each command does one small job extremely well. Pipes let you snap those small jobs together to do something big, without writing any program.
Commands in this lesson
cat notes/todo.txt | wc -lRead a file, then count its lines3
cat penguins/facts.txt | grep penguinRead a file, then keep only matching linesThere are 18 kinds of penguin.
ls | sortList the folder, then sort the namesnotes penguins welcome.txt
history | tail -3Take your last three commands💡 Think of it like this
A pipe is literally a pipe. Whatever the left command shouts goes down the pipe, and the right command catches it.
🔬 The grown-up version
A pipe connects stdout of the left process to stdin of the right one, with no temporary file in between. Long pipelines such as ps aux | grep nginx | awk '{print $2}' | xargs kill are how experienced users solve problems in one line.
Now you try
This terminal is pretend, so you cannot break anything. Tap a chip or type a command yourself.
Quick check
What does the | symbol do?
How do you count the lines in a file using a pipe?
Finished this one?
Mark it done to collect 35 XP and keep your streak growing.