我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
当前回答
重复和案例不敏感的捕捉与线号:
grep -inr "Text" folder/to/be/searched/
其他回答
您可以使用下面的命令,因为您不想要文件名,但您想要从所有文件中搜索。
grep -e TEXT *.log | cut -d' ' --complement -s -f1
捕捉与 -e 选项是相当快的与其他选项相比,因为它是PATTERN 比赛
正如彼得在以前的回答中提到的那样,所有以前的回答都建议抓住并找到。
但有一个更复杂的方式使用Gnome Commander与完美的GUI和数以百万计的选项自2001年以来,并找到文件只是其中之一。
试试这:
find . | xargs grep 'word' -sl
试试:
find . -name "*.txt" | xargs grep -i "text_pattern"
这个捕捉命令会给你一个准确的结果,当你正在寻找特定的文本在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"