grep:忽略 GREP_OPTIONS 搜索区分大小写

Lar*_*sen 10 grep environment-variables case-sensitivity

我已经设置了GREP_OPTIONS="--ignore-case --color"~/.bashrc因为我通常希望 grep 不区分大小写。但是,有时我需要 grep 来实际搜索区分大小写的内容,但手册页没有为此建议参数。

我怎样才能做到这一点?

Ulr*_*gel 11

我可能会用我的选项定义一个别名,例如:

alias grep="grep --ignore-case --color"
Run Code Online (Sandbox Code Playgroud)

因为这只会影响交互式程序而不是脚本。然后,您可以直接运行\grep/bin/grep在没有任何选项的情况下运行它。

如果你想继续使用GREP_OPTIONS你可以为你的命令行取消它,例如

GREP_OPTIONS= grep ....
Run Code Online (Sandbox Code Playgroud)