grep [options] pattern [file...]Arguments explained
- pattern is the text or regex to search for.
- file is optional; grep can read standard input.
- -i ignores case.
- -r searches directories recursively.
- -n shows line numbers.
- -E enables extended regular expressions.
Common examples
grep -n "error" app.logShows matching lines with line numbers.
ps aux | grep nginxFinds process lines containing nginx.
| Field | Details |
|---|---|
| Command | grep |
| Category | Search and Filtering |
| Primary use | Searches text for matching patterns. |
| Syntax | grep [options] pattern [file...] |