JP19
JP19

Reputation:

bash script "unexpected end of file" in simple script

I have a script written in a file.

#!/bin/bash

if [ -f "/bin/uname" ]; then
   OS=`/bin/uname`;
   export OS="${OS}";
else
  echo "Unable to detect OS - modify the appropriate .bashrc to support";
if

If I run it, I get the following error:

./temp.sh: line 9: syntax error: unexpected end of file

However, if I type the same script on bash prompt, it works.

(This piece of code is giving me nightmares. It is included in another large script which is failing due to these 6 lines. I put them in a separate script temp.sh and temp.sh gives the same error)!.

regards,

JP

Upvotes: 0

Views: 1949

Answers (1)

Ruel
Ruel

Reputation: 15780

Your last line should be fi instead of if.

Upvotes: 5

Related Questions