Skip to main content
added 350 characters in body
Source Link
pLumo
  • 23.2k
  • 2
  • 43
  • 70

Why notNew versions of grep have the option --no-ignore-case which overrides -i:

--no-ignore-case
Do not ignore case distinctions in patterns and input data. This is the default. This option is useful for passing to shell scripts that already use -i, to cancel its effects because the two options override each other.

For older versions of grep, you could simply add this as option to your script?

Something like:

#!/usr/bin/bash
if [ "$1" = "--no-ignore-case" ]; then
    shift
    grep -rnI --exclude-dir={.git,obj} --exclude=tags --color=auto "$@"
else
    grep -irnI --exclude-dir={.git,obj} --exclude=tags --color=auto "$@"
fi

Note: --no-ignore-case will need to be the first argument when you call your script.

Why not simply add this as option to your script?

Something like

#!/usr/bin/bash
if [ "$1" = "--no-ignore-case" ]; then
    shift
    grep -rnI --exclude-dir={.git,obj} --exclude=tags --color=auto "$@"
else
    grep -irnI --exclude-dir={.git,obj} --exclude=tags --color=auto "$@"
fi

New versions of grep have the option --no-ignore-case which overrides -i:

--no-ignore-case
Do not ignore case distinctions in patterns and input data. This is the default. This option is useful for passing to shell scripts that already use -i, to cancel its effects because the two options override each other.

For older versions of grep, you could simply add this as option to your script:

#!/usr/bin/bash
if [ "$1" = "--no-ignore-case" ]; then
    shift
    grep -rnI --exclude-dir={.git,obj} --exclude=tags --color=auto "$@"
else
    grep -irnI --exclude-dir={.git,obj} --exclude=tags --color=auto "$@"
fi

Note: --no-ignore-case will need to be the first argument when you call your script.

Source Link
pLumo
  • 23.2k
  • 2
  • 43
  • 70

Why not simply add this as option to your script?

Something like

#!/usr/bin/bash
if [ "$1" = "--no-ignore-case" ]; then
    shift
    grep -rnI --exclude-dir={.git,obj} --exclude=tags --color=auto "$@"
else
    grep -irnI --exclude-dir={.git,obj} --exclude=tags --color=auto "$@"
fi