+ -
当前位置:首页 → 问答吧 → 同样的脚本内容,不同的名字2种不同的执行结果?

同样的脚本内容,不同的名字2种不同的执行结果?

时间:2011-07-06

来源:互联网

[root@localhost ]# cat 2.sh
#!/bin/bash
num=`ps aux|grep tomcat|grep -v grep|wc -l`
echo "$num"

[root@localhost ]# sh 2.sh
3
改名字后的结果,
[root@localhost ]# mv 2.sh check_tomcat.sh
[root@localhost ]# cat check_tomcat.sh
#!/bin/bash
num=`ps aux|grep tomcat|grep -v grep|wc -l`
echo "$num"
[root@localhost ]# sh check_tomcat.sh
6
[root@localhost ]#
不知道bash是不是对脚本名字的长度有限制?
系统版本如下:

[root@localhost ~]# cat /etc/issue
CentOS release 5.5 (Final)
Kernel \r on an \m

[root@localhost ~]# echo $BASH_VERSION
3.2.25(1)-release

作者: zhaoke0128   发布时间: 2011-07-06

回复


你的脚本名也有关键字tomcat,所以。。。。。。。

作者: wtuter   发布时间: 2011-07-06

回复 zhaoke0128

mv 2.sh check_.sh呢
再试试

作者: yinyuemi   发布时间: 2011-07-06

回复 wtuter


    谢谢,脚本名字没有tomcat关键字,就可以了

作者: zhaoke0128   发布时间: 2011-07-06