試す
find /srv/www/*/htdocs/system/application/ -name "*.php" -exec grep "debug (" {} \; -print
 
 これにより、application の下のフォルダーが再帰的に検索されます。 .php のファイルの場合 拡張子を付けて grep に渡します .
これを最適化するには、次を実行します:
find /srv/www/*/htdocs/system/application/ -name "*.php" -print0 | xargs -0 grep -H "debug ("
 
 これは xargs を使用します すべての .php を渡す find で出力されるファイル 単一の grep への引数として コマンド; 例:grep "debug (" file1 file2 file3 . -print0 find のオプション および -0 xargs のオプション ファイル名とディレクトリ名のスペースが正しく処理されていることを確認してください。 -H grep に渡されたオプション すべての状況でファイル名が出力されるようにします。 (デフォルトでは、grep 複数の引数が渡された場合にのみ、ファイル名を出力します。)
man xargs より:
<ブロック引用>
 -0 
- 入力項目は、空白ではなくヌル文字で終了し、引用符とバックスラッシュは特別なものではありません (すべての文字が文字どおりに解釈されます)。他の引数と同様に扱われるファイル文字列の終わりを無効にします。入力項目に空白、引用符、またはバックスラッシュが含まれる可能性がある場合に役立ちます。 GNU find 
 
-print0 オプションは、このモードに適した入力を生成します。
 find grep を使用できます。 直接 (少なくとも GNU grep ):
grep -RH --include='*.php' "debug (" /srv/www/*/htdocs/system/application/
 単一のプロセス フォークに到達しました。
オプション:
-R, --dereference-recursive Read all files under each directory, recursively. Follow all symbolic links, unlike -r.-H, --with-filename Print the file name for each match. This is the default when there is more than one file to search.--include=GLOB Search only files whose base name matches GLOB (using wildcard matching as described under --exclude).--exclude=GLOB Skip any command-line file with a name suffix that matches the pattern GLOB, using wildcard matching; a name suffix is either the whole name, or any suffix starting after a / and before a +non-/. When searching recursively, skip any subfile whose base name matches GLOB; the base name is the part after the last /. A pattern can use *, ?, and [...] as wildcards, and \ to quote a wildcard or backslash character literally.