Reputation: 1
I have a problem with if
in bash script. I've written the following if condition but it produces an error:
if [[ "$capacity" != *10 && "$capacity" != *20 ]] || [[ "$capacity" != *80 && "$capacity" != *100 ]]; then
Simply, I want to compare (two values not equals to) || (two values not equals to) condition using or operator
Upvotes: 0
Views: 63
Reputation: 123410
I took your line and added enough additional lines to make it a Minimal, Complete, and Verifiable example:
#!/bin/bash
capacity=55
if [[ "$capacity" != *10 && "$capacity" != *20 ]] || [[ "$capacity" != *80 && "$capacity" != *100 ]]; then
echo "match"
fi
Then I ran it like this:
$ chmod +x ./myscript
$ ./myscript
match
It wrote "match", exactly as I expected.
Will you please do the same thing?
Upvotes: 1