Mission 2 of 5
Pipes and Filters
Build a small report by connecting focused commands.
Combine small commands into useful pipelines for sorting, counting, cutting, translating, and formatting text.
Mental model
Understand what is happening
A pipe sends stdout from one command into stdin of the next.
sort | uniq is a classic pattern.
Filters transform text without opening an editor.
Guided lab
Work through the mission
Sort and count
Sorts lines and counts adjacent duplicates after sorting.
cd ~/linux-practice
echo -e 'banana\napple\ncherry\napple' > fruits.txt
sort fruits.txt | uniq -cTranslate characters
Transforms text through a pipeline.
echo 'Hello World' | tr 'a-z' 'A-Z'
echo 'Hello World' | tr ' ' '_'Cut and align fields
Extracts fields and prints a simple table.
echo 'Name:Age:City' > people.txt
echo 'Jane:25:London' >> people.txt
cut -d: -f1,3 people.txt
column -t -s: people.txtCheckpoint
Verify the mission
The pipeline produces a sorted, counted report.
Try it yourself
One step without a recipe
Create animals.txt and count duplicates. Use cut to show selected fields.
Need a hint?
Think of each command in a pipe as a workstation on an assembly line. `sort` arranges the parts, `uniq` removes duplicates, `cut` picks what you need, and `tr` swaps labels. Build one station at a time. If the output looks wrong, remove the last pipe segment and check what's coming in.
Explain it back
Before you move on
- What does the | symbol do?
- Why is sort often used before uniq?