我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
我如何在其文件内容中找到包含一个特定的文本序列的所有文件?
下一个不起作用. 它似乎显示系统中的每个单一文件。
find / -type f -exec grep -H 'text-to-find-here' {} \;
当前回答
正如彼得在以前的回答中提到的那样,所有以前的回答都建议抓住并找到。
但有一个更复杂的方式使用Gnome Commander与完美的GUI和数以百万计的选项自2001年以来,并找到文件只是其中之一。
其他回答
试试这:
find . | xargs grep 'word' -sl
试试:
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' {} \;
有一个名为The Silversearcher的新工具
sudo apt install silversearcher-ag
它与 Git 和其他 VCS 密切合作,所以您不会在.git 或其他目录中获得任何东西。
你可以简单地使用
ag "Search query"
它会为你完成任务!
grep -lrnw '/root/Desktop/ipozal' -e 'geolocation'
例如:
我的文件夹名称是“Ipozal”它放在“/root/Desktop”我想在所有文件中找到此文本“地理位置”
grep "text-to-find-here" file_name
或
grep "text-to-find-here" directory_path/*
如果你想搜索当前的目录:
grep "text-to-find-here" *