而条件没有传入TRUE结果。语法有什么问题吗?
RESULT="Exited (0) Less than a second ago"
if [ "$RESULT" = "Exited (0) Less than a second ago" || "$RESULT" = "Stop" ]
then
echo 'exited'
elif [ "$RESULT" = *"Up"* ]
then
echo 'stopped and exited'
else
echo 'Docker already removed'
fi
2条答案
按热度按时间ohfgkhjo1#
以下脚本根据提供的条件正常工作。
我将参数“-o”更改为“[ ]||在tjm3772通知“-o”选项在POSIX 2017中已过时后,
v6ylcynt2#
由于接受的答案是使用POSIX
sh
,因此另一种选择是使用case
语句。help case