Skip to content
Advertisement

How to debug the argument problem in Linux at the bash [closed]

The question is contents of the variable $TEST are equal to the string “success, or the number 5 or the contents of the variable $RESULT

The code that I write is [ $TEST=”success” -o $TEST -eq ”5” -o $TEST = “$RESULT” ], but when in the linux there saying that bash: [ too many argument. Can someone help me

Advertisement

Answer

You will need || for this, to represent or and so:

if [[ "$TEST"==”success” || "$TEST"==”5” || "$TEST" == “$RESULT” ]]
then
      echo "match"
else
      echo "No match"
fi
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement