I am trying the below script in which I am expecting to receive two files in the filesdir folder on date1. If the date is 1 then it should check if two files are received or not, so thats why I m trying to increment a counter "count" each time it iterates and checks the loop. If the date is 1 and file not received then it should wait for few seconds and check again(because surely files will get received). If date is not 1, then it should remove those files and come out of the while loop. I am trying the below.
day_of_month=$(date +%d)
export filesdir=/dir1/dir2/dir3
local count=0
numFilesReceived=0
while true; do
files=$(find $filesdir -name '*.txt.gz' -type f -mmin -1)
if [ "$day_of_month" == "1" ]; then
if [ -f "$files" ]; then
count=$((count + 1))
break
if [ "$numFilesReceived" == "$count" ]; then
echo "All $count data received!"
break 3
fi
fi
else
echo "No data received yet!"
fi
fi
else
rm $files
fi
done
I am not getting what I exactly want. Instead getting errors in the if else part.