if [ $PHONE_TYPE != NORTEL ] || [ $PHONE_TYPE != NEC ] || [ $PHONE_TYPE != CISCO ]thenecho Phone type must be nortel,cisco or necexitfiThe above code did not work for me, so I tried this instead:if [ $PHONE_TYPE == NORTEL ] || [ $PHONE_TYPE == NEC ] || [ $PHONE_TYPE == CISCO ]then:elseecho Phone type must be nortel,cisco or necexitfiAre there cleaner ways for this type of task?
Using the not equal operator for string comparison
linux;shell;shell script
I guess you're looking for:if [ $PHONE_TYPE != NORTEL ] && [ $PHONE_TYPE != NEC ] && [ $PHONE_TYPE != CISCO ]The rules for these equivalents are called De Morgan's laws and in your case meant:not(A || B || C) => not(A) && not(B) && not (C)Note the change in the boolean operator or and and.Whereas you tried to do:not(A || B || C) => not(A) || not(B) || not(C)Which obviously doesn't work.