我如何在其文件内容中找到包含一个特定的文本序列的所有文件?

下一个不起作用. 它似乎显示系统中的每个单一文件。

find / -type f -exec grep -H 'text-to-find-here' {} \;

当前回答

GUI Search Alternative - 用于桌面使用:

因为问题不准确要求命令。

Searchmonkey: Advanced file search tool without having to index your system using regular expressions. 图形相当于查找/查找. 可用于 Linux (Gnome/KDE/Java) 和 Windows (Java) - 开源 GPL v3

特性:

Advanced Regular Expressions Results shown in-context Search containing text Panel to display line containing text 新 2018 更新等。

下载 - 链接:

主页: http://searchmonkey.embeddediq.com/ 下载: http://searchmonkey.embeddediq.com/index.php/download-latest Repo: https://sourceforge.net/projects/searchmonkey/files/

屏幕射击:

此分類上一篇

其他回答

重复和案例不敏感的捕捉与线号:

grep -inr "Text" folder/to/be/searched/

我很感动如何简单的吸引力使它与“rl”:

grep -rl 'pattern_to_find' /path/where/to/find

-r to recursively find a file / directory inside directories..
-l to list files matching the 'pattern'

使用“r”而不“l”以查看文件名跟随文本中的模式!

grep -r 'pattern_to_find' /path/where/to/find

它只是完美工作......

您可以使用下面的命令,因为您不想要文件名,但您想要从所有文件中搜索。

grep -e TEXT *.log | cut -d' ' --complement -s -f1

捕捉与 -e 选项是相当快的与其他选项相比,因为它是PATTERN 比赛

找到与 xargs 是优先的,当有许多潜在的比赛可以通过. 它运行比其他选项更慢,但它总是工作. 正如一些发现,xargs 不处理文件与嵌入空间默认。

这里是 @RobEarl 的答案,增强,以便处理文件与空间:

find / -type f | xargs -d '\n' grep 'text-to-find-here'

下面是 @venkat 的答案,同样增强:

find . -name "*.txt" | xargs -d '\n' grep -i "text_pattern"

这里是 @Gert van Biljon的答案,同样增强:

find . -type f -name "*.*" -print0 | xargs -d '\n' --null grep --with-filename --line-number --no-messages --color --ignore-case "searthtext"

以下是 @LetalProgrammer 的答案,同样增强:

alias ffind find / -type f | xargs -d '\n' grep

这里是 @Tayab Hussain的答案,同样增强:

find . | xargs -d '\n' grep 'word' -sl

如果您严格想要使用查找,则使用查找 + 查找:

找到 /path/to/somewhere/ -type f -exec grep -nw 'textPattern' {} \;

步骤:

使用查找搜索文件,执行捕获所有。

这给了你找到文件的权力。

使用 -name 模式,如果您只想捕捉某些文件:

找到 /path/to/somewhere/ -type f -name \*.cpp -exec grep -nw 'textPattern' {} \;

您可以使用不同的搜索选项来改善您的文件搜索。