我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
当前回答
所有以前的答案都建议抓住和找到,但还有另一种方式:使用中夜指挥官
它是一个免费的工具(30年,时间证明),它是视觉的没有GUI. 它有许多功能,找到文件只是其中之一。
其他回答
正如彼得在以前的回答中提到的那样,所有以前的回答都建议抓住并找到。
但有一个更复杂的方式使用Gnome Commander与完美的GUI和数以百万计的选项自2001年以来,并找到文件只是其中之一。
这个捕捉命令会给你一个准确的结果,当你正在寻找特定的文本在Linux -
grep -inRsH “文本要被搜索” /path/to/dir(它可以是“。
i stands for ignore case distinctions R stands for recursive and it also includes symlinks. It is better to use 'R' instead of 'r' n stands for "it will print line number." s stands for "suppress error messages" H stands for "it will print the file name for each match"
下面是可以用于搜索文件的几个命令列表。
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
您可以使用 ripgrep 将遵守默认项目的.gitignore 文件。
此分類上一篇
拒绝许可的错误:
rg -i rustacean 2> /dev/null
将默认错误(stderr)输出转向 /dev/null。
使用 pwd 从您所在的任何目录中搜索,向下滑动
grep -rnw `pwd` -e "pattern"
取决于您正在使用的 grep 版本,您可以忽略 pwd. 在更新的版本中,如果没有目录,则似乎是 grep 的默认情况。
这样:
格雷普 -rnw -e “模式”
或
格雷普 -rnw “模式”
他们会像上面那样做!