To set my default options for grep
(from MSYS in Win7) to ignore object files and specific dirs, I exported
GREP_OPTIONS
to ~/.profile
as follows:
export GREP_OPTIONS='--exclude=*.{o,obj,pyc} --exclude-dir={.git,_Output}'
export GREP_COLOR='1;32'
Even after restarting the shell for my .profile
to take effect, my call to grep
still
searches object files. However, the GREP_COLOR
variable seems to work. I even tried explicitly setting my options in the same shell before executing grep
:
$ grep --version
GNU grep 2.5.4
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ export GREP_OPTIONS='--exclude=*.{o,obj,pyc} --exclude-dir={.git,_Output}'
$ echo $GREP_OPTIONS
--exclude=*.{o,obj,pyc} --exclude-dir={.git,_Output}
$ grep $GREP_OPTIONS -r foo .
grep: ./bar.o: Permission denied
./baz.c:My foo text
$ grep --exclude=*.{o,obj,pyc} --exclude-dir={.git,_Output} -r foo .
./baz.c:My foo text
How do I get grep
to automatically use GREP_OPTIONS
from ~/.profile
?