method 1:
egrep -irn --exclude="tags" --exclude="cscope.*" --exclude-dir=".repo/" --exclude-form=<PATH>/exclude.list PATTERN
method 2:
egrep -irn "PATTERN" | egrep -v "tags|cscope|.repo"
3. 如果每次都输入--exclude-dir=参数,是不是很慢还容易出错,降低效率呢?
不过不用担心,我们可以把--exclude-dir=参数通过加入配置文件 ~/.bashrc (这是bash的当前用户配置文件) 的方法来简化操作,提高效率。
在~/.bashrc文件的末尾添加以下命令:
- export GREP_OPTIONS="--exclude-dir=pattern"