Find all files containing a specific text on Linux with grep
The standard tool is grep. To search every file under a folder:
grep -rn "some text" /path/to/folder
-rsearches directories recursively.-nprints line numbers.-lprints only the names of files that contain a match.-iignores upper/lower case.-Ftreats the pattern as a fixed string, not a regular expression.
List only file names
grep -rl "some text" .
Only some file types
grep -rn --include="*.php" "some text" .
Skip a folder
grep -rn --exclude-dir=node_modules "some text" .
Quote the text so the shell does not change it. Binary files can be skipped with -I.