Linux 结构化命令

if -then 语句

if -then 语句有如下格式

if command

then 

commands

f i

bash shell 的if语句会先运行if后面的那个命令,如果改命令的退出状态码是0的话,位于then 部分的命令就会被执行,如果该命令的状态码是其他值的话。then部分的命令就不会被执行,bash shell 会继续执行脚本中的下一个命令,f i 语句表示if -then 语句到此结束

说明:if-then 语句还有另外一种形式

if command ;then

commands

f i

if-then-else语句

if command

then

commands

else

commands

f i

原文地址:https://www.cnblogs.com/zhang-jun-jie/p/9848134.html