Use grep -l :
-l, --files-with-matches
Suppress normal output; instead print the name of each input file from
which output would normally have been printed.
Por exemplo,
$ echo foo > file1
$ echo bar > file2
$ grep -l foo *
file1
Ou com números de linha em que a string ocorreu:
$ grep -rn foo .
file1:1:foo