令人困惑的语法错误:意外的文件结束

时间:2012-11-01 15:50:07

标签: bash

当我尝试运行它时,我的bash脚本中出现以下错误,我似乎无法找到问题。我认为这与我如何关闭我的循环有关。任何帮助将不胜感激

bash: random: line 66: syntax error: unexpected end of file

以下是我的代码

#!/bin/bash
one=$RANDOM
two=$RANDOM

# Declare variable choice and assign value 4
choice=5
# Print to stdout
echo "1. -l"
echo "2. -m"
echo "3. -c"
echo "4. -i"
echo -n "Please choose a word [1,2,3,4]? "
while [ $choice -eq 5 ]; do


  #option -l
  if [ $choice -eq 1 ] ; then
   #do something

      else
      echo "Please make a choice between 1 -4 !"
      echo "1.-l"
      echo "2.-m"
      echo "3.-c"
      echo "4.-i"
      echo -n "Please choose a word [1,2,3 or 4]? "
      choice=5

      fi

echo"finished"
done

编辑*删除了庞大的代码,因为它导致了缩进问题。

1 个答案:

答案 0 :(得分:4)

你还没有为你的while循环做done

while [ $choice -eq 5 ]; do
   ...lots of stuff ...
done <---you're missing this