C.W.K.
Stream
Lesson 09 of 10 · published

Real-World One-Liners

~13 min · one-liner, compose

Level 0Window Tourist
0 XP0/95 lessons0/14 achievements
0/100 XP to next level100 XP to go0% complete

Recipes that solve real questions

This lesson is a small cookbook. Each one-liner answers a concrete question with the tools you've now seen. Run them, modify them, save the patterns you'll reuse.

What's eating my disk?

du -sh ~/.* */ 2>/dev/null | sort -h | tail

Most-used commands in my history

history | awk '{print $2}' | sort | uniq -c | sort -rn | head

Top 10 IPs in an access log

awk '{print $1}' access.log | sort | uniq -c | sort -rn | head

Lines of code per language in a repo

find . -type f -name '*.*' \
  | grep -vE 'node_modules|\.git|__pycache__' \
  | awk -F. '{print $NF}' \
  | sort | uniq -c | sort -rn

All TODOs by file

grep -rn TODO --include='*.py' --include='*.ts' \
  --exclude-dir={node_modules,.git} . | head

Find duplicate lines in a file

sort file | uniq -d

Convert ISO timestamps to local time

awk '{cmd="date -j -f %Y-%m-%dT%H:%M:%S " $1 " +%H:%M"; cmd | getline lt; close(cmd); print lt, $0}'

Strip ANSI color codes from a captured log

sed -E 's/\x1B\[[0-9;]*[mK]//g' colored.log

What changed in the last 60 minutes?

find ~ -type f -mmin -60 -not -path '*/.cache/*' 2>/dev/null

Show only the URLs in my browser bookmarks export

grep -oE 'https?://[^"]+' bookmarks.html | sort -u | head

Code

Memorise this disk-usage one-liner·bash
du -h --max-depth=1 ~ 2>/dev/null | sort -h | tail -10
# Or pure POSIX
du -sh ~/.* */ 2>/dev/null | sort -h | tail

External links

Exercise

Pick three one-liners from this lesson. Run each, then modify it for your context (your repo, your log, your dotfiles). Paste the variants into a personal cheatsheet — that's the only way they stick.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.