shopt -s nocaseglob
ext=.csv
if [[ $i != "IMCO_"*$ext ]]; then
thecondition is only recognizing when $i (which is a filename) ends with the extension (.csv) in lowercase.
I need it to recognize .CSV uppercase as well
shopt -s nocaseglob
ext=.csv
if [[ $i != "IMCO_"*$ext ]]; then
thecondition is only recognizing when $i (which is a filename) ends with the extension (.csv) in lowercase.
I need it to recognize .CSV uppercase as well
nocaseglob
only applies to filename expansion.
Your code works fine if you enable nocasematch
instead.
This prints Match
:
i="IMCO_FOO.CSV"
shopt -s nocasematch
ext=.csv
if [[ $i != "IMCO_"*$ext ]]; then
echo "No match"
else
echo "Match"
fi
Using regex:
ext=csv
shopt -s nocasematch
if [[ $i =~ ^IMCO_.*\.${ext}$ ]]; then