bash脚本"简单脚本中的意外文件结束"

0 bash

我有一个写在文件中的脚本.

#!/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
Run Code Online (Sandbox Code Playgroud)

如果我运行它,我会收到以下错误:

./temp.sh: line 9: syntax error: unexpected end of file
Run Code Online (Sandbox Code Playgroud)

但是,如果我在bash提示符下键入相同的脚本,它可以工作.

(这段代码给了我噩梦.它包含在另一个由于这6行而失败的大脚本中.我把它们放在一个单独的脚本temp.sh和temp.sh给出了同样的错误)!

问候,

J.P

Rue*_*uel 5

你的最后一行应该是fi代替if.