Skip to content
Clairos Learn

Text and logs · Lesson 8 of 38 · 7 minutes

Port text review

Read, sort, and count a training port list.

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

Admin work often includes tiny text inventories.

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.

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.

tail
Show the end of an input; -n selects the number of lines.

This browser lab snapshots output; it does not keep a live tail -f stream.

Worked example and expected result
$ cat data/ports.txt | sort | uniq
22
23
443
80

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

$ wc -l data/ports.txt
5 data/ports.txt

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

$ tail -n 3 data/ports.txt
443
23
22

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 “Port text review”, which interpretation is safe?

Apply it elsewhere

Before adapting the wc workflow from “Port text review” to another server, what should you do?

Keep the momentum.

Complete the lab, then explain and apply the pattern.

Next: Config text compareTry 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. 01Pipeline countsFilter logs through safe text pipelines.Practice
  2. 02Config text compareUse grep and diff to compare two config snapshots.Practice
  3. 03Journal windowsRead only the last few simulated journal lines.Practice