syntax error near unexpected token `if'
bash, if-statement, linux, scripting, ubuntu
Solution
I think you're just missing the do clause of the `for` loop:
#declare $PICPATH, etc...
for file in $PICPATH; do
if [ ${file -5} == ".jpeg" -o ${file -4} == ".jpg" ];
then
#do some exif related stuff here.
else
#throw some errors
fi
done
Problem
I am currently trying to write a bash script which helps me step through a directory and check for .jpeg or .jpg extensions on files. I've come up with the following: ``` #declare $PICPATH, etc... for file in $PICPATH if [ ${file -5} == ".jpeg" -o ${file -4} == ".jpg" ]; then #do some exif related stuff here. else #throw some errors fi done ``` Upon execution, bash keeps throwing a an error on the if line: "syntax error near unexpected token `if'. I'm a completely new to scripting; what is wrong with my if statement? Thanks.