请问我下面的脚本有什么错误,没找出来啊?
文件名:sleep.sh
echo -n Count:
tput sc
count=0;
while true;
do
if[$count -lt 40 ];
then let count++;
sleep 1;
tput rc
tput ed
echo -n $count;
else exit 0;
fi
done
执行以后提示错误信息如下:
Count:./sleep.sh: line 8: syntax error near unexpected token `then'
./sleep.sh: line 8: `then let count++;'
[解决办法]
if [ $count -lt 40 ] 注意空格。
另外加这么多;干什么,又不是C
[解决办法]
while true; 后面没有分号。、
[解决办法]
楼主 用 sh -x t1.sh 执行,看到底是哪里出错了,改一下。
多分号,少空格 这样的小错误就不要出现了吧,
- Perl code
[root@bogon temp]# sh -x t1.sh + $'\r': command not found+ $'\r': command not found+ echo -n $'Count:\r'+ tput $'sc\r''put: unknown terminfo capability 'sc+ $'\r': command not found+ count=0+ $'\r': command not foundt1.sh: line 18: syntax error: unexpected end of file