我试图检查该PHONE_TYPE
变量是否包含三个有效值之一。
if [ "$PHONE_TYPE" != "NORTEL" ] || [ "$PHONE_TYPE" != "NEC" ] ||
[ "$PHONE_TYPE" != "CISCO" ]
then
echo "Phone type must be nortel,cisco or nec"
exit
fi
上面的代码对我不起作用,所以我尝试了一下:
if [ "$PHONE_TYPE" == "NORTEL" ] || [ "$PHONE_TYPE" == "NEC" ] ||
[ "$PHONE_TYPE" == "CISCO" ]
then
: # do nothing
else
echo "Phone type must be nortel,cisco or nec"
exit
fi
有没有更清洁的方式来执行此类任务?
if [[ ! $PHONE_TYPE =~ ^(NORTEL|NEC|CISCO)$ ]]; then