Practice: Log Detective
Grep in action.
Something went wrong on the website this morning. Customers say the shop page broke. Let's use grep to investigate the log, like a detective.

- The shop page broke
- Investigate the log
- grep is our magnifying glass
Your questions
Here are three questions. How many errors were there in total? Which errors involved the shop page? And did the user jo have any problems at all? Pause, and try answering them with grep.
The answers
Grep dash C ERROR counts seven errors. Grep failed slash shop shows the shop errors, with their times. And for jo, we search for jo, and then hide the INFO lines, using a pipe into grep dash V. Jo had two slow pages, and one error, on the shop page.
grep -c ERROR logs/server.log 7 grep "failed /shop" logs/server.log 2026-01-05 09:07:00 ERROR jo failed /shop 2026-01-05 09:17:21 ERROR alex failed /shop grep jo logs/server.log | grep -v INFO 2026-01-05 09:03:58 WARN jo slow page /cart 2026-01-05 09:07:00 ERROR jo failed /shop 2026-01-05 09:26:18 WARN jo slow page /home
Thinking like a detective
Notice how we narrowed things down, one step at a time. Start broad, like all errors. Then add a detail, like the page. Then combine searches with a pipe. That's how people really investigate problems on servers.
| key | value |
|---|---|
| Start broad | grep ERROR |
| Add detail | grep "failed /shop" |
| Combine | grep jo | grep -v INFO |
| Count | grep -c |
Summary
You investigated a real log, by counting, narrowing down, and combining searches. Next, the pipe itself, the most powerful idea in the shell.
Key takeaways- Count with -c
- Narrow down
- Combine with |