Compound If Tests
If you need to combine more than one test to see whether a condition is met, you can use the syntax from the one-line conditionals (&& and ||) to create compound conditionals. Keep in mind that the && causes the execution of the command to its right only if the command to its left reports success status. Well, suppose the command to its left is an if test? This would result in the left test being performed, and if the test evaluates to true (success), the if test to the right of the && will also execute, and so forth. Essentially, the && functions as a logical and in this case. This means that the entire logical and evaluates to true only if both the if tests evaluate to true.
Likewise, the || functions as a logical or, which ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access