Reputation: 79
I am a beginner at unix and this is my first for loop with if statement. I am getting an error which says syntax error near unexpected token 'then'. Please can you help me fix this. What have i done wrong.
for file in $@
do
if [[ ! -f $@ ]]
then
echo "Error. File does not exist."
exit $ERROR_NO_FILE
elif
then
chmod 755 $file
echo "File permissions have been changed."
exit $SUCCESS
fi
done
Upvotes: 0
Views: 52
Reputation: 3215
there is an extra elif/then
in the middle. Try replacing it with an else
exit $ERROR_NO_FILE
else
chmod 755 $file
Upvotes: 1