我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
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/
是
屏幕射击:
此分類上一篇
其他回答
您可以使用 ack. 它就像输入源代码. 您可以扫描您的整个文件系统。
只是做:
ack 'text-to-find-here'
在你的根目录中。
您也可以使用常规表达式,指定文件类型等。
更新
我刚刚发现The Silver Searcher,这类似于Ack,但比它快3至5倍,甚至忽略了来自.gitignore 文件的模式。
使用:
grep -c Your_Pattern *
这将报告您的模式在当前目录中的每个文件中有多少副本。
A Simple find can work handy. alias it in your ~/.bashrc 文件:
alias ffind find / -type f | xargs grep
开始一个新的终端和问题:
ffind 'text-to-find-here'
如果你有一组文件,你会一直在检查,你可以列出他们的路径,例如:
alias fd='find . -type f -regex ".*\.\(inc\|info\|module\|php\|test\|install\|uninstall\)"'
然后你可以简单地过滤列表如下:
grep -U -l $'\015' $(fd)
将列表 fd 过滤到包含 CR 模式的文件。
我发现,将我感兴趣的文件会帮助我创建更容易的脚本,然后总是试图记住如何获得所有这些文件。 回复的物品工作,但早或晚你将不得不争取分散特定的文件类型。
你的命令是正确的. 你只需要添加 -l 来抓住:
find / -type f -exec grep -l 'text-to-find-here' {} \;