我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
当前回答
grep "text-to-find-here" file_name
或
grep "text-to-find-here" directory_path/*
如果你想搜索当前的目录:
grep "text-to-find-here" *
其他回答
您可以使用以下命令从文件中找到特定文本:
cat file | grep 'abc' | cut -d':' -f2
您可以使用下面的命令,因为您不想要文件名,但您想要从所有文件中搜索。
grep -e TEXT *.log | cut -d' ' --complement -s -f1
捕捉与 -e 选项是相当快的与其他选项相比,因为它是PATTERN 比赛
使用:
grep -c Your_Pattern *
这将报告您的模式在当前目录中的每个文件中有多少副本。
重复和案例不敏感的捕捉与线号:
grep -inr "Text" folder/to/be/searched/
试试:
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' {} \;