CC 4.0 BY-SA 版权协议网址:https://creativecommons.org/licenses/by-sa/4.0/deed.z
站主补充:
补充一:Shell if 单判断的格式
if [ <judgment condition> ];then
<step to perform>
fi
补充二:Shell if 双判断的格式
if [ <judgment condition> ];then
<step to perform>
else
<step to perform>
fi
补充三:Shell if 多判断的格式
if [ <judgment condition> ];then
<step to perform>
elif
<step to perform>
else
<step to perform>
fi
补充四:Shell if 多条件判断的格式
4.1 与条件的判断
if [ <judgment condition> -a <judgment condition> ];then
<step to perform>
fi
或者:
if [ <judgment condition> ] && [ <judgment condition> ];then
<step to perform>
fi
4.2 或条件的判断
if [ <judgment condition> -o <judgment condition> ];then
<step to perform>
fi
或者:
if [ <judgment condition> ] || [ <judgment condition> ];then
<step to perform>
fi
补充五:Shell if 可以使用所有 Linux 的 [] 命令和 [[]] 命令的案例作为判断条件