Linux, terminal and Git

Stage 3 · Lesson 4 of 8

Sort, uniq, cut and wc

Text tools

A few small tools turn raw text into answers. sort puts lines in order (-n sorts as numbers, -r reverses). uniq -c counts repeated lines, but only when the repeats sit next to each other.

cut -d, -f2 takes the second column of comma-separated text. tr swaps or deletes characters, and wc -l counts lines. Chained together, sort | uniq -c | sort -rn | head is a classic .

It gives the most common items in anything, such as the that appear most in a log. Because uniq only neighbouring lines, sort always comes first.

Common traptrusting cut on files with quoted commas, where a real CSV tool is safer.

A question to check yourself, an AI practice session and 1 cheat sheet entry come when you add the roadmap to your account. Add it

Resources for this stage

Start with· follow one of these

Practise

  • Test regular expressions on sample text with a plain explanation of each part

  • Middle levels need grep, sort, uniq and find to locate the next password

Keep handy

  • The official jq manual with examples for every filter

  • Quick examples for find, sed, awk and friends when you forget the syntax

Mark this stage as not done?