Skip to the workspace
Pebellslearn by building
Terminal Knowledge  ›  Lesson

Text Manipulation — Slicing Logs With Small Tools

Text Manipulation 12 minUnix text tools such as grep, awk, cut, sed, sort, uniq and wc each do one job on a stream of lines and combine through pipes to answer questions about logs.

devops / Text Manipulation — Slicing Logs With Small Tools

Explore each scene at your own pace.

01 · The rule

The rule

Text Manipulation — Slicing Logs With Small Tools

notes-api suddenly slows down and you suspect one client is hammering it. The answer is in a 200 MB access log. You could open it in an editor and scroll, or you could get the top five clients with one line of commands in a few seconds.

The rule

Small tools, one job each, joined by pipes.

Unix text tools each do one thing to a stream of lines. The pipe (a vertical bar in the shell) sends one tool's output into the next. The essential set:

Tool Its one job Example
grep keep lines that match grep " 500 " access.log
cut take fields by a delimiter cut -d, -f2 users.csv
awk take whitespace-separated fields, do small logic awk '{print $1}' access.log
sed find and replace sed 's/http:/https:/g' links.txt
sort order lines sort -n for numbers, -r to reverse
uniq -c collapse adjacent repeats and count them
wc -l count lines
head / tail first or last lines; tail -f follows a growing file

A line of our access log looks like this:

203.0.113.9 - - [12/Mar/2026:10:15:02 +0000] "GET /notes/42 HTTP/1.1" 200 512

The first field is the client IP, so this pipeline finds the busiest clients:

awk '{print $1}' access.log | sort | uniq -c | sort -rn | head -5
Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.