即使顶级目录没有.txt文件,'grep -R string * .txt'也是如此 [英] 'grep -R string *.txt' even when top dir doesn't have a .txt file
问题描述
我不记得在 grep 中引入了递归搜索' -R '命令行开关时,但现在我无法想象没有它的生活。
唯一的问题是,如果递归中的任何目录没有匹配文件名通配符,则grep -R将停止并将无法报告目录和文件这样做会产生正面的搜索结果。
例如: grep -R skeleton_app * .xml
只会报告
AndroidManifest.xml:< application android:label =@ string / skeleton_app>
同时:
grep -R skeleton_app *
会报告所有内容:
AndroidManifest.xml:< application android:label =@ string / skeleton_app>
二进制文件bin / classes.dex匹配
二进制文件bin / com / example / android / skeletonapp / R $ string.class匹配
gen / com / example / android / skeletonapp/R。 java:public static final int skeleton_app = 0x7f050000;
res / values / strings.xml:< string name =skeleton_app>了解Intents< / string>
我的问题:有没有办法告诉' grep -R '' 停止文件名不匹配?
b $ b
grep -R --include'* .xml'skeleton_app。
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?
Try:
grep -R --include '*.xml' skeleton_app .
这篇关于即使顶级目录没有.txt文件,'grep -R string * .txt'也是如此的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!