如何递归地grep? [英] How do I grep recursively?

查看:124
本文介绍了如何递归地grep?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何递归地 grep 所有目录和子目录?

 找 。 | xargs greptexthere* 


解决方案

  grep -rtexthere。 

第一个参数表示要搜索的正则表达式,而第二个参数表示应该是的目录搜索。在这种情况下,表示当前目录。



注意:这适用于GNU grep,并且在某些平台像Solaris一样,你必须特别使用GNU grep而不是传统的实现。对于Solaris,这是 ggrep 命令。

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.

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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆