nocasematch
.
mytext="eXistenZ"
if [[ $mytext =~ existenz ]];
then
echo "yep"
else
echo "nope"
fi
If you run the above script you should get "nope" as the output. For case insensitive matching just insert this into the script prior to the regex:
shopt -s nocasematch;
You can unset the
nocasematch
shell option using the following: shopt -u nocasematch
Here's a more complete example:
mytext="eXistenZ"
function testText
{
if [[ $mytext =~ existenz ]];
then
echo "yep"
else
echo "nope"
fi;
}
testText
shopt -s nocasematch
testText
If you run that script then the output is:
nope
yep