Lesson 10 / 29
Searching with grep
Find lines matching a pattern.
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).