Advanced Bash-Scripting Guide: An in-depth exploration of the art of shell scripting | ||
---|---|---|
Prev | Chapter 7. Tests | Next |
Condition tests using the if/then construct may be nested. The net result is equivalent to using the && compound comparison operator.
1 if [ condition1 ] 2 then 3 if [ condition2 ] 4 then 5 do-something # But only if both "condition1" AND "condition2" valid. 6 fi 7 fi |
Example 34-4 demonstrates a nested if/then condition test.