如何自动忽略文件的grep [英] how to automatically ignore files in grep
本文介绍了如何自动忽略文件的grep的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么办法寻找的东西,东西相当于svnignore或gitignore的时候才能使用grep忽略某些文件?我搜索源$ C $ C时,通常会使用这样的事情。
Is there any way I could use grep to ignore some files when searching something, something equivalent to svnignore or gitignore? I usually use something like this when searching source code.
grep -r something * | grep -v ignore_file1 | grep -v ignore_file2
即使我可以成立一个别名grep来忽略这些文件将是一件好事。
Even if I could set up an alias to grep to ignore these files would be good.
推荐答案
- 排除在grep的选项也将工作:
--exclude option on grep will also work:
grep perl * --exclude=try* --exclude=tk*
这在文件中搜索perl的当前目录中排除文件与试或TK开始
This searches for perl in files in the current directory excluding files beginning with try or tk
这篇关于如何自动忽略文件的grep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文