# Searching with grep — Linux

Source: https://www.geekswithgeeks.com/en/linux/linux-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.

```bash
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)`.
