linux shell编程 二

条件选择 if -then  语句

if command
then
    commands
fi
另一种形式
if command; then
    commands
fi

关于退出状态码,你只需要记住:正常退出(命令执行正常)的状态码是0, 非正常退出的状态码不是0(有不少)。

以上语句的语义为: 如果if后面的命令执行正常(状态码0),那么就执行then后面的语句。否则不执行。 fi代表if语句的结束

 if ——then -else语句

if command
then
    commands
else
    commands
fi

2.test命令用于判断条件是否成立  数值比较,,字符创比较,文件比较

猜你喜欢

转载自blog.csdn.net/qq_41826183/article/details/85393699