如何grep只显示路径/文件名? [重复]

时间:2022-09-01 22:12:50

This question already has an answer here:

这个问题在这里已有答案:

I'm trying to locate the files which contain certain pattern, so I use grep -ir 'pattern' . to search all files under current directory. But I don't want to see the content of each file, I only need the path/filename. How can I do that?

我正在尝试找到包含特定模式的文件,因此我使用grep -ir'pattern'。搜索当前目录下的所有文件。但我不想看到每个文件的内容,我只需要路径/文件名。我怎样才能做到这一点?

Ps: Because some JSON file contains very long text in one line, then it will occupy the whole screen. I don't want to filter out those JSON files, because that's what I'm trying to locate

Ps:因为某些JSON文件在一行中包含很长的文本,所以它将占据整个屏幕。我不想过滤掉那些JSON文件,因为这就是我想要找到的

1 个解决方案

#1


16  

grep -l will output JUST the names of files which matched, without showing the actual match.

grep -l将输出JUST匹配的文件的名称,而不显示实际匹配。

#1


16  

grep -l will output JUST the names of files which matched, without showing the actual match.

grep -l将输出JUST匹配的文件的名称,而不显示实际匹配。