我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
当前回答
试试:
find / -type f -exec grep -H 'text-to-find-here' {} \;
将搜索所有文件系统,因为 / 是根文件夹。
Home 文件夹使用:
find ~/ -type f -exec grep -H 'text-to-find-here' {} \;
目前使用文件夹:
find ./ -type f -exec grep -H 'text-to-find-here' {} \;
其他回答
下面是可以用于搜索文件的几个命令列表。
grep "text string to search” directory-path
grep [option] "text string to search” directory-path
grep -r "text string to search” directory-path
grep -r -H "text string to search” directory-path
egrep -R "word-1|word-2” directory-path
egrep -w -R "word-1|word-2” directory-path
按要求轻松自定义下面的命令,并从文件中重复找到任何行。
grep -i hack $(find /etc/ -type f)
所有以前的答案都建议抓住和找到,但还有另一种方式:使用中夜指挥官
它是一个免费的工具(30年,时间证明),它是视觉的没有GUI. 它有许多功能,找到文件只是其中之一。
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/
是
屏幕射击:
此分類上一篇
Silver Searcher 是一个可怕的工具,但 ripgrep 可能甚至更好。
它在Linux、Mac和Windows上运行,并在几个月前在Hacker News上编写(它有一个链接到Andrew Gallant的博客,其中有一个GitHub链接):
Ripgrep - 新命令线搜索工具