I am attempting to build a loop to check for files in a folder then run a loop if files exist in the folder and keep running the loop until no more files are left, but I am running into the token error, "syntax error near unexpected token `do'. Here is the script I am trying to run.
files=/satellite/MSGVIS6/*
if [ "${#files[@]}" -gt 0 ]; then
do
mcenv << 'EOF'
imgcopy.k MSGVI6D MSGVI6I BAND=1 SIZE=SAME
imgremap.k MSGVI6I MSGVI6I.2 SIZE=ALL PRO=MERC RES=3.00
imgcha.k MSGVI6I.2 STYPE=GVAR
imgdel.k MSGVI6I.1
exit
EOF
find /satellite/awips/ -type f -name 'AREA6022*' -exec mv '{}' /awips2/edex/data/manual/ \;
rm -rf "$files"
done
else
echo ''
echo "No files downloaded. New area files will not be created."
fi
exit 0
Any thoughts on what I may be writing incorrectly?
do
out and put a semicolon betweenif [ "${#files[@]}" -gt 0 ]; then
or put thethen
onto the next line.