Louis I. answered 06/18/19
Computer Science Instructor/Tutor: Real World and Academia Experienced
First, I'm not sure what works in the single bracket [ ] test any longer ... modern versions of korn shell and bash encourage usage of the double bracket [[ ]]
Similar to your example above, see below.
Use && for logical AND and || for logical OR ..
This worked under both ksh and bash ...
a=1
b=4
c=3
d=4
if [[ $a -eq 1 && $b -eq 2 || $c -eq 3 && $d -eq 4 ]]
then
echo ok
else
echo "No go"
fi
ok
Also, this is shorthand for the above - this works also if you don't need an "else" logical branch:
$ [[ $a -eq 1 && $b -eq 2 || $c -eq 3 && $d -eq 4 ]] && echo ok
ok