Search for a String Inside Files from the Command Line
To get a list of files containing a specific string within a directory (and its subdirectories), you can use the grep command with the proper options.
Command to use
grep -rnw 'directory' -e "pattern"
Parameters
- directory: the path where the search should be performed (e.g.,
/var/www
) - pattern: the string or expression you want to find inside the files
The command will return the matching files, including the line number and the content of the matching line.