Syntax error near unexpected token 'fi'

Posted by Bill Sherwin on Server Fault See other posts from Server Fault or by Bill Sherwin
Published on 2010-03-24T14:37:29Z Indexed on 2010/03/24 14:43 UTC
Read the original article Hit count: 451

Filed under:
|
|
|

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

© Server Fault or respective owner

Related posts about syntax

Related posts about error