Groups of compound conditions in Bash test [duplicate]
I want to have some groups of conditions in a Bash if statement. Specifically, I'm looking for something like the following:
if <myCondition1 and myCondition2> or <myCondition3 and myCondition4> then...
How may I group the conditions together in the way I describe for use with one if statement in Bash? I thank you for any ideas you may have on this.
Use the && (and) and || (or) operators:
if [[ expression ]] && [[ expression ]] || [[ expression ]] ; then
They can also be used within a single [[ ]]:
if [[ expression && expression || expression ]] ; then
And, finally, you can group them to ensure order of evaluation:
if [[ expression && ( expression || expression ) ]] ; then