使用grep查找不包含给定字符串模式的文件 [英] Using grep to find files that don't contain a given string pattern

查看:121
本文介绍了使用grep查找不包含给定字符串模式的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的Web应用程序中使用以下命令来查找当前目录中包含字符串 foo (忽略svn目录)的所有文件。

I'm using the following command in my web application to find all files in the current directory that contain the string foo (leaving out svn directories).

find .  -not  -ipath '.*svn*' -exec  grep -H -E -o  "foo"  {} \; > grep_results.txt

如何查找不包含单词 foo

推荐答案

最后我用朋友的建议, / p>

Finally I got it right using this as suggested by a friend:

find .  -not  -ipath '.*svn*' -exec  grep  -H -E -o -c  "foo"  {} \; | grep 0

它给出了所有与 foo :)

这篇关于使用grep查找不包含给定字符串模式的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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