Skip to content
Clairos Learn

Text and logs · Lesson 4 of 38 · 9 minutes

Text pipelines

Use safe simulated pipes to count, sort, and deduplicate text output.

Mastery 0/3Run itExplain itApply it
learner@clairosSimulated Linux lab
learner@clairos:~ $
↑ history · Tab complete · Ctrl+C cancel · Esc, Tab to leaveExit 0

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 | wc
1 3 16

Exit status: 0. The command completed successfully in the training fixture.

$ cat /home/learner/data/ports.txt | sort | uniq
22
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.

Try a variation

Repeat this workflow in the sandbox with a different scratch filename. Keep the system fixtures unchanged and compare the observed output with your expectation before moving on.

Explain it

In “Text pipelines”, which interpretation is safe?

Apply it elsewhere

Before adapting the cat workflow from “Text pipelines” to another server, what should you do?

Keep the momentum.

Complete the lab, then explain and apply the pattern.

Next: Paging logsTry an incident drill

Anonymous 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.

Keep learning

  1. 01Log triageInspect access, error, auth, and service logs in a cautious order.Practice
  2. 02Paging logsUse less, head, and tail to read logs in chunks.Practice
  3. 03Case-insensitive searchFind text regardless of capitalization.Practice