在shell中流程控制分为两类:一类是循环,一类是判断选择。
1、if判断结构
if expression;then
command
fi
2、if/else判断结构
if expression;then
command
else
command
fi
3、if/elif/else
if expression;then
command
else
if expression;then
command
else
comamnd
fi
fi
另外一种简洁写法
if expression;then
command
elif expression;then
command
elif expression;then
command。。。。。。
fi
4、case判断结构
case var in
var1)command;
var2)command;
var3)command;
.。。。。。。
*)command;
esac