Linux tricks, one-liners & shell magic
← Back to all tricks
Search inside files recursively

Use grep to search through all files in a directory tree for a pattern, showing filenames and line numbers.

bash
$ grep -rn 'search_term' /path/to/dir/ # Case-insensitive, show 2 lines of context: grep -rin -C2 'error' /var/log/
tux422026-04-19
Delete this trick? This cannot be undone.