Text pipelines
Use safe simulated pipes to count, sort, and deduplicate text output.
Understand the pattern
Pipelines make terminals powerful, but this lab keeps them tightly limited.
echo- Write simple text to standard output. Prefer printf when exact formatting matters.
Redirection can overwrite an existing file before the command runs.
wc- Count input. -l counts newline characters, -w counts whitespace-delimited words, and -c counts bytes.
Text without a final newline may have fewer counted lines than visible rows.
cat- Read one or more files to standard output without editing their contents.
Reading a source file should precede changing it; avoid printing real secrets.
sort- Order lines before comparing or grouping them; -n compares numerically and -r reverses order.
Alphabetical sorting is not numeric sorting.
uniq- Collapse adjacent duplicate lines; use sort first when duplicates are not already together.
uniq does not find every duplicate in an unsorted stream.
Worked example and expected result
$ echo alpha beta beta | wc1 3 16
Exit status: 0. The command completed successfully in the training fixture.
$ cat /home/learner/data/ports.txt | sort | uniq22 23 443 80
Exit status: 0. The command completed successfully in the training fixture.
$ echo pipeline-practice > lab-pipeline.txt(no output; exit 0)
Exit status: 0. The command completed successfully in the training fixture.
Explain it
Apply it elsewhere
Keep the momentum.
Complete the lab, then explain and apply the pattern.
Next: Paging logsTry an incident drillAnonymous lesson and mastery progress lasts for this session. Sign in to keep synced lesson XP between sessions; mastery stays device-local. No speed bonus, lost lives, or hint penalties.