这是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
最佳答案
不知道怎么回事,但你的脚本包含奇怪的空白字符,十六进制编辑器显示 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
关于linux - Centos 6.6 shell 脚本 - 意外 token 附近出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29861073/