这是shell脚本代码,当我在centos 6.6中使用时,会收到两条错误信息....
./script12.bash: line 11: syntax error near unexpected token `$1'
./script12.bash: line 11: `case $1 in'
你能帮我找到错误吗?
#! /bin/bash
num=0
until [ "$num" -eq 30 ]
do
echo -n "Please input a number here : "
read num
if [ "$num" -gt 30 ] ; then
echo "$num" is too big , try again.
echo
elif [ "$num" -eq 30 ] ; then
echo BINGO !! you got it.
else
echo "$num" is too small , try again.
echo
fi
done
答案 0 :(得分:0)
不确定你的脚本是如何包含奇怪的空白字符,十六进制编辑器显示ASCII码80个字符,这似乎混淆了bash。用普通空格(ASCII代码20)替换它们时,以下工作:
#!/bin/bash
num=0
until [ "$num" -eq 30 ]
do
echo -n "Please input a number here : "
read num
if [ "$num" -gt 30 ] ; then
echo "$num" is too big , try again.
echo
elif [ "$num" -eq 30 ] ; then
echo BINGO !! you got it.
else
echo "$num" is too small , try again.
echo
fi
done