您的位置:首页 > 其它

ubuntu 使用sh 无法执行脚本文件的解决方法

2012-02-16 17:12 786 查看
最近刚开始学习linux shell语言

看的是鸟哥的私房菜,里面有讲到执行shell脚本有两种方法:

1. 设置执行属性: chmod 755 file

执行(如果已经在当前目录) : ./file

2. 使用: sh file 执行

.但是在vmware里装的ubuntu 11.10却无法执行

#!/bin/bash
declare -i s
for (( i = 1; i <= 100;i = i+1 ))
do
s=s+i
done
echo "The count is ==> $s"


使用第二种方法执行时出现 :

test04_for.sh: 1: declare: not found

test04_for.sh: 3: Syntax error: Bad for loop variable

百度了下网上,解决方法:

在终端中输入:

sudo dpkg-reconfigure dash

然后出现的界面中选择 NO

然后就能正确运行了。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐