前言
在部署程序或者执行定时任务等需求时,会使用到逻辑判断的shell脚本语言
逻辑使用
与
-
形式:
条件1 与 条件2 -
使用方法一
if [ $value == "stop" -a $value == "restart" ]; then
excute=$value
fi
- 使用方法二
if [ $value == "stop" ] && [ $value == "restart" ]; then
excute=$value
fi
或
-
形式:
条件1 或 条件2 -
使用方法一
if [ $value == "stop" -o $value == "restart" ]; then
excute=$value
fi
- 使用方法二
if [ $value == "stop" ] || [ $value == "restart" ]; then
excute=$value
fi
结语
… …