ubuntu执行脚本时报错

学着编写简单的脚本:(使用的机器为ubuntu 10.4)
具体的脚本如下:
cheng@cheng-laptop:~/sh$ cat 3.sh
#!/bin/bash
#it is use for test
#create time 2010/8/24
#made by chenbaocheng
nu1=1+9*3
declare -i nu2=1+9*3
echo $nu1
echo $nu2
在执行的时候一直报错:
cheng@cheng-laptop:~/sh$ sh 3.sh
3.sh: 6: declare: not found
1+9*3
搜了Google便 知需要使用bash 3.sh就可以了。
cheng@cheng-laptop:~/sh$ bash 3.sh
1+9*3
28
**********************************************
看完Ubuntu declare使用问题你肯定有不少收获,希望本文能教会你更多东西。在shell的执行上用户root和普通用户是不一样的。使用vi /etc/passwd我们就可以看到在用户的最后一行也就是定义shell执行位置的地方root的位置是/bin/bash 而其他的用户都是/bin/sh 所以在Ubuntu中root执行scipt的时候应该是bash test.sh(注意在linux中是没有 文件后缀名的加上只是为了识别特殊的文件。文件能不能执行主要是看文件属性里面的x是否北打开)而不是sh test.sh。