SkillByAIOpen interactive version →

Lesson 11 / 31

Searching with grep

Search text with grep using case-insensitive, recursive and line-number options plus basic regular expressions.

What grep does

grep scans text for lines matching a pattern and prints them. It's one of the most-used commands in daily Linux work.

Basic & recursive search

-i ignores case, -r searches recursively through a directory, -n shows line numbers.

grep "error" app.log
grep -in "error" app.log
grep -r "TODO" src/

Output:

12:2026-09-04 ERROR connection refused

A little regex goes far

^ matches line start, $ line end, . any character, grep -E enables extended regex like (foo|bar).