I wrote some function that should find a directory inside a parent directory, but the thing is that it's taking to long, probably it's searching in the subdirectories as well. Here is my code:
function findMspDir () {
mountedDir=/opt/SwDrop/
dirToSearch=/opt/SwDrop/Repository/
if [ ! -d $mountedDir ]; then
echo "The directory hasn't been found"
exit 1;
else
echo "The directory is mounted"
subDirToSearch="MSP-$versionNum"
# mspDir=`find $dirToSearch -name $subDirToSearch`
mspDir=$(find /opt/SwDrop/Repository/ -name 'MSP-1.5.1.4')
if [ "$mspDir" = "" ]; then
echo "The MSP directory hasn't been found"
exit 1;
fi
fi
echo "The found directory is: $mspDir"
}
I know for sure that the directory that i'm looking for is under /opt/SwDrop/Repository/
and it can't be in the subdirectories.
Any idea how to solve it ?
find -maxdepth 1 -name "you_name" -a type d