R string *.txt' even when top dir doesn't have a .txt file

I don't recall when the recursive search ' -R ' command line switch was introduced in grep , but now I can't imagine life without it.

Its only problem is that if any directory in the recursion doesn't have a match for the filename wildcard, grep -R will stop and will fail to report the directories and files that do produce positive search results.

For example:

  grep -R skeleton_app *.xml

Will report only

AndroidManifest.xml:    <application android:label="@string/skeleton_app">

While:

  grep -R skeleton_app *

Will report all:

AndroidManifest.xml:    <application android:label="@string/skeleton_app">
Binary file bin/classes.dex matches
Binary file bin/com/example/android/skeletonapp/R$string.class matches
gen/com/example/android/skeletonapp/R.java:        public static final int skeleton_app=0x7f050000;
res/values/strings.xml:    <string name="skeleton_app">Understanding Intents</string>

My question: Is there a way to tell ' grep -R ' not to stop on filename mismatch?


尝试:

grep -R --include '*.xml' skeleton_app .

除了grep之外,还使用find

$ find ./ -name "*.txp" -exec grep "string" '{}' ; -print
链接地址: http://www.djcxy.com/p/78052.html

上一篇: 如何在Mac OSX上使用Zsh shell和`sed`命令重命名文件

下一篇: R string * .txt',即使top dir没有.txt文件