Syntax error near unexpected token 'fi'
- by Bill Sherwin
I have created a very simple script (see below) but cannot get it to run properly. I always get messages saying
line 5: syntax error near unexpected token 'fi'
line 5: 'fi'
when I try to execute this script.
#!/bin/sh
rm /opt/file_name
if $? -ne 0 then
echo 'error'
fi
exit
I am running this on Red Hat Linux if that makes any difference.
If any one can help identify what is wrong with the if statement I'd really appreciate it.
Bill