Skip to content
Latchkey

grep -i: Case-Insensitive Log Searches

grep -i ignores the difference between upper and lower case when matching.

Logs are inconsistent about case (Error, error, ERROR), so case-insensitive search catches them all. -i pairs with almost every other flag.

What it does

grep -i (--ignore-case) makes the pattern match without regard to letter case, so grep -i error matches "Error", "ERROR", and "error". It applies to both the literal characters and character classes in the pattern.

Common usage

Terminal
grep -i error build.log
grep -i "failed\|exception" app.log
some-command | grep -i warning

Options

FlagWhat it does
-i / --ignore-caseMatch case-insensitively
-nShow line numbers alongside the match
-cCount matching lines instead of printing them
-wMatch whole words only

In CI

When scanning third-party tool output you do not control, prefer -i so a capitalization change does not silently drop a match. If you intentionally want exact case (matching a specific token), leave -i off so unrelated text does not trip the gate.

Common errors in CI

A grep that "stopped catching errors" after a tool upgrade often changed the case of its log level; adding -i restores the match. Note -i still exits 1 when nothing matches, so it remains subject to the set -e no-match gotcha; guard with || true where a miss is acceptable.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →