【发布时间】:2018-06-28 16:44:46
【问题描述】:
我最近开始编写 BASH 脚本,目前正在尝试使用 while 循环。但是,当我运行以下代码块时,命令提示符会响应:
run.command: line 12: syntax error near unexpected token `done'
run.command: `done'
然后程序关闭。 这是我正在运行的代码。
#!/bin/bash
echo -e "text"
c=false
while true; do
printf ">> "
i=read
if [$i = "exit"]; then
exit
else if [$i = "no"]; then
echo "no"
else
echo -e "Error: $i is undefined"
fi
done
我对 while 循环进行了一些研究,但我的循环语法似乎是正确的。当我在最后删除完成时,会发生Unexpected end of file 错误。任何帮助将不胜感激!
【问题讨论】:
标签: bash