[toc] if条件语句if语法单分支123456789101112131415161718# 写法一:if [ ];then cmd1 cmd2fi # 写法二:if [ ]then cmd1 cmd2fi ## 不过单分支,没有必要写if了,直接用条件表达式即可。[ 条件 ] && { cmd1 cmd2} if语法双分支123456789101112131415161718# 写法一:if [ ];then cmd1 cmd2else cmd1 cmd2fi # 写法二:if [ ]then cmd1 cmd2else cmd1 cmd2fi if语法多分支12345678910111213141516171819202122232425# 写法一:if [ ];then cmd1 cmd2elif [ ];then cmd1 cmd2else cmd1 cmd2fi # 写法二:if [ ]then cmd1 cmd2elif [ ]then cmd1 cmd2else cmd1 cmd2fi