admin管理员组

文章数量:1026989

if [ $#

在shell脚本中经常会使用if [ $# -ne 1 ];then。。。这类脚本

if [ $# -ne 1 ];then

这段命令是用于判断参数的个数是否为1,不是则进行then的逻辑处理,其中$#表示参数个数,-ne是不等于

示例:

#判断参数个数
if [ $# -ne 1 ];thenecho "参数个数不为1"exit
elseecho "参数个数为1"
fi

一个参数:

没有参数: 

 多个参数:

 

转载于:.html

if [ $#

在shell脚本中经常会使用if [ $# -ne 1 ];then。。。这类脚本

if [ $# -ne 1 ];then

这段命令是用于判断参数的个数是否为1,不是则进行then的逻辑处理,其中$#表示参数个数,-ne是不等于

示例:

#判断参数个数
if [ $# -ne 1 ];thenecho "参数个数不为1"exit
elseecho "参数个数为1"
fi

一个参数:

没有参数: 

 多个参数:

 

转载于:.html

本文标签: if