分页: 1 / 1
关于一个脚本出现的问题!
发表于 : 2007-08-28 10:03
由 valhelsing
我最近在学习脚本,其中有一个脚本的内容如下:
#!/bin/bash
declare -i i
declare -i s
while [ "$i" != "101" ]
do
s=s+i
i=i+1
done
echo "the result is ==> $s"
然后我运行此脚本结果SHELL提示说:declare:no found
这是什么原因呢?
发表于 : 2007-08-28 10:15
由 iblicf
no problem
发表于 : 2007-08-28 10:37
由 valhelsing
可我运行的时候确实是出现了 declare:no found!~
发表于 : 2007-08-28 10:42
由 bones7456
你确定头上的:
#!/bin/bash
没有写成:
#!/bin/sh
或者是:
#!/bin/dash
?
发表于 : 2007-08-28 10:45
由 valhelsing
确定~!~
发表于 : 2007-08-28 10:50
由 bones7456
代码: 全选
lily@LLY:~/test$ ll /bin/bash
-rwxr-xr-x 1 root root 700560 2007-04-11 07:32 /bin/bash
lily@LLY:~/test$ cat ttt
#!/bin/bash
declare -i i
declare -i s
while [ "$i" != "101" ]
do
s=s+i
i=i+1
done
echo "the result is ==> $s"
lily@LLY:~/test$ ./ttt
the result is ==> 5050
lily@LLY:~/test$
我这边正常,无语了。
发表于 : 2007-08-28 11:00
由 valhelsing
那我在试试!~