Stage 3 · Lesson 4 of 8
Sort, uniq, cut and wc
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
- CourseFreeThe Missing Semester of Your CS Education
MIT · Beginner
The data wrangling lecture walks through grep, sed, awk and regular expressions on real logs
- BookFreeThe Linux Command Line
William Shotts · Beginner
Clear chapters on text processing, regular expressions and searching for files