linux之grep用法

运用场景:在当前目录下查找,比如代码目录,不需要在.svn目录下,以及ctags生成的tags文件中查找:

  grep的--exclude-dir=参数就是为了排除某个目录的,即不包含等号后面的目录;

  grep的--exclude=参数是为了排除某个特定的文件的,即不包含等号后面的文件;

  grep -nr --exclude="tags" --exclude-dir=".svn"    "VmOffNetwork"  *

一劳永逸的办法加入到/root/.bashrc里面:

  export GREP_OPTIONS="--exclude=tags --exclude-dir=.svn"

 root@u18# source  /root/.bashrc

 即可,使用grep自动带上改选项;

原文地址:https://www.cnblogs.com/chris-cp/p/4624245.html