To look up files recursively in the given directory
To look up files recursively in the given directory for the given text, and display the file name with line number that has the matching text:
grep -rHn "text to search" /path/to/dir
To use a search pattern, use the following command
grep -rHn -e "text pattern to search" /path/to/dir
r
– search recursively
H
– display the file name with the matching text
n
– display the line number in the file with the matching text
To exclude one or more folders from the search
grep -rn --exclude-dir={<comma-separated-folder-paths>} <search-term> .
Above grep excludes public
and resources
folders from the search