i was wondering if anyone could help me.
i am writing a program that looks in directories for a certain file. i have multiple directories inside a project folder some contain the file and others don't.
project
folderwithfile1
folderwithfile2
folderwithfile3
folderwithoutfile
if this file exists in one of these folders, my program will sanitizes the file path to remove the filename result would be
home/newcoder/Desktop/project/folderwithfile1
home/newcoder/Desktop/project/folderwithfile2
home/newcoder/Desktop/project/folderwithfile3
now i would like to exclude/ignore certain folders from the search even if they contain the file. for example lets exclude folderwithfile1 and folderwithfile2.
my current code is
exclusionFilePaths=('/home/newcoder/Desktop/project/folderwithfile1' '/home/newcoder/Desktop/project/folderwithfile2')
for i in $(find ~+ -type f -name "fileWantToFind.php")
do
sanitized=${i%/*}
for key in "${exclusionFilePaths[@]}";
do
if [ $sanitized == $key ]
then
echo $sanitized
#ignore and continue
else
echo veryLongCommand
fi
done
done
the result of my program is this
no
/home/newcoder/Desktop/project/folder1
/home/newcoder/Desktop/project/folder3
/home/newcoder/Desktop/project/folder3
/home/newcoder/Desktop/project/folder2
no
what am i doing wrong ? any help is appreciated, thank you.