How do I search string recursively in the filesystem with grep command? Linux grep command is a frequently used command by most of the Linux users. Using grep you can search any string in all files available in the directory hierarchy. You will get come examples of grep command to search any string recursively in the filesystem.
Grep command uses following syntax to search pattern Recursively in all files available under specific directory and its sub directories.
$ grep -R "search-pattern" /path/to/search/dir
Search Pattern Recursively in Files:
Search for pattern “example.com” in all files available under /var/www/html directory.
$ grep -R "
Search Pattern Recursively in Specific Extension Files:
Make your search more specific, like search a string “example.com” in all files with the extension .php only. To achieve this use
--include option to force grep to search for the specific file only and ignore others.
$ grep -R
You may also specify multiple file extensions to search
$ grep -R
--include="*.php" --include="*.conf""example.com" /var/www/html