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

时间:2010-11-19 07:39:45

标签: 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

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

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

但是,如果我在bash提示符下键入相同的脚本,则可以正常工作。

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

的问候,

JP

1 个答案:

答案 0 :(得分:5)

您的最后一行应该是fi而不是if