grep list each file once

I'm looking some text in files , but three are a lot of files and searched text appears several times in one file, how can I receive a list of files that contains searched text with every file listed only once?


Solution 1:

grep -l xyz file*

where xyz is the search pattern , and file* is the list of files to be searched in

Solution 2:

grep -l LIST PATTERN is the way to go. Alternatively one could use xargs to do the same thing:

xargs grep "My Search Pattern"  < input.txt 

xargs is particularly useful when you would want to use grep on several filenames passed from a pipe, for instance:

find ~/Documents ~/bin -print0 | xargs -0 grep 'Search Term'