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 ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.