I'm trying to write a script that removes all the .jpg's that end in an odd number. This is my code:
#!/bin/bash
echo "start\n"
for f in *.jpg
do
fname=$(basename "$f")
echo "fname is $fname\n"
fname="${filename%.*}"
echo "fname is $fname\n"
if[$((fname % 2)) -eq 1 ] then
echo "removing $fname\n"
rm $f
fi
done
When I run it it outputs start and then says "syntax error near unexpected token 'fi'"
When I had then on the line after if it said "syntax error near unexpected token 'then'"
How do i fix this?