Grep在目录中搜索string1和string2中的所有文件 [英] Grep Search all files in directory for string1 AND string2
本文介绍了Grep在目录中搜索string1和string2中的所有文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在cygwin中使用grep来查找包含 BOTH 这两个词的所有文件。
这是我用来搜索的内容在一个目录中的所有文件递归一个字:
grep -rdb-connect.php。
如何扩展上述内容以查找既包含db-connect.php又包含 版本。
我试过这个: grep -rdb-connect.php \ | version。
但这是一个OR,即它得到的文件包含一个或另一个。
感谢所有帮助
解决方案
grep -r db-connect.php。 | grep版本
How can I make use of grep in cygwin to find all files that contain BOTH words.
This is what I use to search all files in a directory recursively for one word:
grep -r "db-connect.php" .
How can I extend the above to look for files that contain both "db-connect.php" AND "version".
I tried this: grep -r "db-connect.php\|version" .
but this is an OR i.e. it gets file that contain one or the other.
Thanks all for any help
解决方案
grep -r db-connect.php . | grep version
这篇关于Grep在目录中搜索string1和string2中的所有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文