18May/090
BASH case insensitive path checking. (effificently)
I needed to check some paths for files. I have a script that calls a copy function on some files that were previously mounted on a case insensitve system. I couldn't find anything, so instead of using `find -i` which would be a resource hog i wrote this: -
#!/bin/bash
old_IFS=$IFS
if ! [ -a $1 ]; then
trypath=""
path=""
IFS=$'/'
for i in $1; do
trypath=$path$i"/"
if [[ -a $trypath ]]; then
path=$trypath
else
ipath=`ls "$path" | grep -i $i`
path=$path$ipath"/"
fi
done
echo "$path"
else
echo "exists"
fi
IFS=$old_IFS












