List the files containing a particular word in their text
I would like to list the files recursively and uniquely that contain the given word.
Example: Checking for word 'check', I normal do is a grep
$ grep check * -R
But as there are many occurrence of this word, I get a lot of output. So I just need to list the filenames that contain the given search word. I guess some trick with
xargswould suffice here, but not sure.
--files-with-matchesoption which is documented as follows:
Suppress normal output; instead print the name of each input file from which output would normally have been printed. The scanning will stop on the first match. (
-lis specified by POSIX.)
So, for you example you can use the following:
$ grep check * -lR