`
85977328
  • 浏览: 1870717 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

ubuntu报错Syntax error: "(" unexpected解决方法

 
阅读更多
今天跟着练习一个shell scripts,内容如下:
=======================================
#!/bin/bash
# Using for and loop
# allen 2010/04/13
declare -i s # <==变量宣告
for (( i=1; i<=100; i=i+1 ))
do
        s=s+i
done
echo "The count is =l
=======================================
但是运行时总是报下面这个错,如下:
test11-loop.sh: 5: Syntax error: Bad for loop variable
几经查找语法,没有问题,后来在网上找到问题原因:
代码对于标准bash而言没有错,因为Ubuntu为了加快开机速度,用dash代替了传统的bash,是dash在捣鬼。
解决方法是 取消dash
sudo dpkg-reconfigure dash
在选择项中选No,即可。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics