Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
375 views
in Technique[技术] by (71.8m points)

linux - 如何递归grep?(How do I grep recursively?)

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

find . | xargs grep "texthere" *
  ask by wpiri translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
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.

(注意:这适用于GNU grep,在某些平台(如Solaris)上,必须专门使用GNU grep而不是传统实现。)

For Solaris this is the ggrep command.

(对于Solaris,这是ggrep命令。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...