← Lessons/Pipes & Filters
← Pipes & Filters

Filter the failures

Learn

Filters keep what matters

A filter is a tool that reads text, transforms it, and writes text back out. The one you'll reach for most is grep PATTERN: it keeps only the lines that match the pattern and drops the rest.

grep ERROR access.log

grep reads access.log line by line and prints just the lines containing ERROR. Two details worth knowing:

  • It's case-sensitive: ERROR and error are different patterns (grep -i ignores case).
  • It matches anywhere in the line, so ERROR finds 500 ERROR as well as a line that merely mentions an error.

In access.log, the failed requests are the ones marked ERROR.

Show only the failed requests — the lines containing ERROR — with grep.

sandbox@opspath: ~
OpsPath sandbox · Debian GNU/Linux 12 · GNU bash 5.2
Each command runs in a fresh, isolated sandbox with this lesson's files in ~.
Nothing carries over between commands, so chain with && or | when you need to.
Type a command and press Enter. ↑/↓ history · Ctrl+L clear · Ctrl+C cancel line
# ── Step 2 · Filter the failures ──
# Sign in to run commands — it's free.