Grep: Ignoring GREP_OPTIONS to search case-sensitive

case sensitivityenvironment-variablesgrep

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?

Best Answer

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 ....
Related Question