Skip to content
Lab 2 of 4

Text Pipelines: Answer Neha's Questions from a Log

On the night of 9 October, orders failed for a while. Neha needs numbers, the vendor needs a redacted log, and Simran wants the slowest endpoints. Answer all three from 7,000 lines of the API's own log with grep, awk, sed, sort and uniq.
  • Beginner
  • 44 min
  • Bash
  • grep
  • awk
  • sed
  • Kestrel

Overview

On the evening of 9 October some orders failed. Neha Arora in finance wants to know how many, and when, so she can match them against payment refunds. Simran Gill has exported that day's request log from the orders API to ~/incident/orders.log.1 — about 7,400 lines, one per request:

2026-10-09T21:14:03 POST /orders 503 12ms

No database, no dashboard: just text, and the five tools that have answered questions like these for fifty years. You will count precisely with grep, group by hour with awk, sort and uniq -c, redact order numbers with sed for an outside vendor, and finally chain all of them into one pipeline that ranks Kestrel's slowest endpoints.

The log has traps for careless patterns — exactly like real logs do.

What you will learn

  • Count exactly what you mean with grep, not everything that contains the digits
  • Split lines into fields with awk and pull out the hour
  • Count and rank with sort | uniq -c | sort -rn
  • Rewrite text safely with sed -E into a new file
  • Compose filter → normalise → count → rank into one pipeline

Before you start

  • You can run commands in a Linux shell and redirect output with >
  • Seen a pipe (|) before; we build everything else up

Tasks

  1. 01Count the right thing with grep
  2. 02When did it happen? awk, sort and uniq -c
  3. 03Redact a copy with sed
  4. 04One pipeline, one answer

Next in this course