Show matching lines and their line numbers.
grep -n 'error' app.logSearch text for a pattern. Use -R for directories and -n to show line numbers.
grep [OPTION]... PATTERN [FILE...]Show matching lines and their line numbers.
grep -n 'error' app.logSearch .conf files recursively, ignoring case and showing line numbers.
grep -Rni --include='*.conf' 'timeout' ./config| Option / clause | Description |
|---|---|
-i, --ignore-case | Ignore case distinctions. |
-n, --line-number | Print line numbers with matching lines. |
-r, --recursive | Search directories recursively (follow symlinks to files). |
-v, --invert-match | Select lines that do not match. |
-E, --extended-regexp | Interpret PATTERN as an extended regular expression. |
-F, --fixed-strings | Treat PATTERN as a list of literal strings. |
-w, --word-regexp | Match whole words. |
-l, --files-with-matches | Print only names of files with matches. |
Review a command and its target before running it. Commands that alter files, services, accounts, disks, permissions or databases may be difficult to reverse. Test in a safe environment and keep backups.