簡単なファイル検索には、grep の -l を使用できます と -r オプション:
grep -rl "mystring"
すべての検索は grep によって行われます。もちろん、他のパラメータでファイルを選択する必要がある場合は、 find が正しい解決策です:
find . -iname "*.php" -execdir grep -l "mystring" {} +
execdir オプションは、各ディレクトリごとに各 grep コマンドを構築し、ファイル名を 1 つのコマンドのみに連結します (+ ).
標準オプション grep -l (小文字の L) でこれを行うことができます。
Unix 標準から:
-l
(The letter ell.) Write only the names of files containing selected
lines to standard output. Pathnames are written once per file searched.
If the standard input is searched, a pathname of (standard input) will
be written, in the POSIX locale. In other locales, standard input may be
replaced by something more appropriate in those locales.
-H も必要ありません
grep(1) から マニュアルページ:
-l, --files-with-matches 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. (-l is specified by POSIX.)