0

当我尝试运行它时,我的 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

编辑* 删除了导致缩进问题的笨重代码。

4

1 回答 1

4

你还没有done为你的 while 循环做一个:

while [ $choice -eq 5 ]; do
   ...lots of stuff ...
done <---you're missing this
于 2012-11-01T15:51:41.680 回答