Linux で grep を使用してファイル名だけを表示するにはどうすればいいですか? [closed] 質問する

Linux で grep を使用してファイル名だけを表示するにはどうすればいいですか? [closed] 質問する

どのように使用すればいいですかグレップLinux でファイル名だけ (インライン一致なし) を表示するにはどうすればいいですか?

私は通常次のようなものを使用しています:

find . -iname "*php" -exec grep -H myString {} \;

一致なしでファイル名(パス付き)だけを取得するにはどうすればいいですか?xargs? 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この場合も必要ありません。

おすすめ記事