Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have set GREP_OPTIONS="--ignore-case --color" in ~/.bashrc as I normally want grep to work case-insensitive. However, there are times when I need grep to actually search case-sensitive, but the man page doesn´t suggest a param for this.

How can I achieve this?

share|improve this question
add comment

1 Answer 1

up vote 8 down vote accepted

I probably would define an alias with my options, e.g.:

alias grep="grep --ignore-case --color"

as this would only affect interactive programs and not scripts. You could then just run \grep or /bin/grep to run it without any options.

If you want to keep using GREP_OPTIONS you can just unset it for your commandline, e.g.

GREP_OPTIONS= grep ....
share|improve this answer
    
+1 didn't know about the \command-name is used to refer to the original command and not the alias. Really helpful. –  mtk Mar 1 '13 at 10:27
    
possibly relevant: unix.stackexchange.com/q/35789/4098 –  rahmu Mar 1 '13 at 10:53
1  
@mtk see unix.stackexchange.com/questions/39291/… for other methods –  Ulrich Dangel Mar 1 '13 at 10:59
1  
"command grep" : will launch the grep command (ie, the one found in the $PATH) even if there is an alias or functino with the same name. Usefull to prepend a "command" to actual command's use in alias and function definitions (and elsewhere when you want to bypass any eventual alias or function definition of the same cmd) –  Olivier Dulac Mar 1 '13 at 13:15
    
GREP_OPTIONS= grep did the trick. Thx! –  Larsen Mar 5 '13 at 11:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.