如何在目录及其所有子目录中grep字符串? [英] How to grep a string in a directory and all its subdirectories?
本文介绍了如何在目录及其所有子目录中grep字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在LINUX中grep目录中的字符串或文本及其所有子目录的文件?
How to grep a string or a text in a directory and all its subdirectories'files in LINUX ??
推荐答案
如果您的grep支持 -R
,请执行以下操作:
If your grep supports -R
, do:
grep -R 'string' dir/
如果没有,则使用 find
:
find dir/ -type f -exec grep -H 'string' {} +
这篇关于如何在目录及其所有子目录中grep字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文