I'm doing the following:
if [ -f $FILE ] ; then
echo "File exists"
fi
But I want the -f
to be case-insensitive. That is, if FILE is /etc/somefile
, I want -f to recognize /Etc/SomeFile
.
I can partially work around it with glob:
shopt -s nocaseglob
TARG='/etc/somefile'
MATCH=$TARG* #assume it returns only one match
if [[ -f $MATCH ]] ; then
echo "File exists"
fi
but the case-insensitive globbing works only on the filename portion, not the full path. So it won't work if TARG is /Etc/somefile
.
Is there any way to do this?