码迷,mamicode.com
首页 > 系统相关 > 详细

linux shell scripts:Syntax error: Bad for loop variable

时间:2014-11-18 16:01:51      阅读:226      评论:0      收藏:0      [点我收藏+]

标签:style   ar   使用   sp   for   div   on   代码   ad   

运行脚本报错

#!/bin/bash

s=0
for (( i=1; i<=100; i++ ))
do
	s=$(( $s + $i ))
done

echo $s

sh add.sh 报错:

add.sh: 4: Syntax error: Bad for loop variable

代码没有错误,Ubuntu为了加快开机速度,用dash代替bash。

解决办法:取消dash,使用bash:

sudo dpkg-reconfigure dash

选择No选项

linux shell scripts:Syntax error: Bad for loop variable

标签:style   ar   使用   sp   for   div   on   代码   ad   

原文地址:http://blog.csdn.net/love254443233/article/details/41247337

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!