shell if多重判断
时间: 2024-01-05 21:20:56 浏览: 98
linux shell中if的各种判断
以下是shell中多重判断的示例:
1. 单层条件判断式:
```shell
if [ 条件判断式 ]; then
command1
fi
```
例如:
```shell
if [ "${Yn}" == "Y" ]; then
echo "yes"
exit 0
fi
```
2. 三层条件判断式:
```shell
if [ 条件判断式1 ]; then
command1
elif [ 条件判断式2 ]; then
command2
else
command3
fi
```
例如:
```shell
if [ 条件1 ]; then
command1
elif [ 条件2 ]; then
command2
else
command3
fi
```
阅读全文