How do I recursively generate a text file which has a list of all files on my server which contain a specific string anywhere in the files?
I know the following command can be used to replace a string recursively
find /var/www -type f -print0 | xargs -0 sed -i 's/old string/new string/g'
I do not want to replace the string, I just want a list of all files which contain the string.
Best Answer
Use
grep
instead ofsed
:From the way you phrase the question, it seems like you're not yet too familiar with
grep
. Read more about its options in its man page type:man grep
at your command line.update to answer comment -- try adding the
-l
option to show just file names. The-i
makes the search case insensitive. The easy to use both is with a single dash:grep -il