我将哪些参数传递给 grep 以仅返回文件名?

Emm*_*myS 5 command-line grep

我正在尝试使用 grep 在我的 Web 服务器上的一堆文件中查找特定文本。没问题,除了它返回的信息比我想要的多!理想情况下,它只会返回一个文件列表,如果文本存在于文件中的多个位置,它只会列出文件名一次。

目前我正在使用这样的东西:

grep -ir essay_ "mysite"
Run Code Online (Sandbox Code Playgroud)

在我网站的所有目录中对单词 essay_ 进行不区分大小写的递归搜索。它返回的内容是这样的:

mysite/dot/contest_declaration.php:$questions = $db->get_results("SELECT * FROM dot_essay WHERE active = 1 order by display_order asc");
mysite/dot/contest_declaration.php:     $db->query("DELETE FROM dot_essay_xref WHERE entry_id = $svar_entry_id");
mysite/dot/contest_declaration.php:     $id = $question->essay_id;
mysite/dot/contest_declaration.php:     $answer = ${"essay_$id"};
shoppermarketexpo/dot/print_declaration.php:        $questions = $db->get_results("SELECT * FROM dot_essay WHERE active = 1");
Run Code Online (Sandbox Code Playgroud)

我想回来的是:

mysite/dot/contest_declaration.php
mysite/dot/print_declaration.php
Run Code Online (Sandbox Code Playgroud)

les*_*ana 9

   -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.)
Run Code Online (Sandbox Code Playgroud)

来自 grep 联机帮助页