本文介绍了如何递归地grep所有目录和子目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何递归grep
所有目录和子目录?
How do I recursively grep
all directories and subdirectories?
find . | xargs grep "texthere" *
推荐答案
grep -r "texthere" .
第一个参数代表要搜索的正则表达式,第二个参数代表要搜索的目录.在本例中,.
表示当前目录.
The first parameter represents the regular expression to search for, while the second one represents the directory that should be searched. In this case, .
means the current directory.
注意:这适用于 GNU grep,并且在某些平台(如 Solaris)上,您必须专门使用 GNU grep,而不是传统实现.对于 Solaris,这是 ggrep
命令.
Note: This works for GNU grep, and on some platforms like Solaris you must specifically use GNU grep as opposed to legacy implementation. For Solaris this is the ggrep
command.
这篇关于如何递归地grep所有目录和子目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!