Lion Cipher Lab

Process text with grep, sed, and awk

Why it matters

Almost every real security task ends with a wall of text: a log file, a config, the output of some tool. The people who move fast aren't reading it line by line — they're carving it up with three tiny commands that have been on every Unix box for 50 years. grep pulls the lines that matter, awk breaks a log into columns and does the counting, sed rewrites text on the way past. Learn this one toolkit and log triage, hunting for an attacker's IP, or tallying the top offenders stops being a chore and becomes a thirty-second reflex — and every later log-analysis lab stops assuming a skill you…

What you'll learn

Steps in this lab

  1. The one idea: three tools, three jobs
  2. Build a sample log to work on (cat > with a heredoc)
  3. grep: find the lines that matter
  4. grep: context lines when one line isn't enough
  5. awk: pull a specific column
  6. awk: count and sum with arrays and END
  7. The pro pipeline: sort | uniq -c | sort -rn for top-N
  8. sed: rewrite text on the way past
  9. sed -i: the flag that edits the real file (and can bite)
  10. Judgment: why this, not that — and when NOT to reach for these
  11. You now own the log-triage reflex

Open the full interactive lab →