首页 > 系统服务 > 详细

linux shell scripts:Syntax error: Bad for loop variable

时间:2017-04-22 15:26:56      阅读:182      评论:0      收藏:0      [点我收藏+]

执行脚本报错

#!/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

原文:http://www.cnblogs.com/zhchoutai/p/6747755.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!