Concept Flow - if-then-else
Start
Evaluate condition
Execute THEN block
End
Execute ELSE block
End
The script checks a condition. If true, it runs the THEN part; if false, it runs the ELSE part, then ends.
if [ "$num" -gt 10 ]; then echo "Greater than 10" else echo "10 or less" fi
| Step | Condition | Condition Result | Branch Taken | Output |
|---|---|---|---|---|
| 1 | [ "$num" -gt 10 ] | True | THEN | Greater than 10 |
| 2 | End of if-then-else | - | - | - |
| Variable | Start | After Step 1 | Final |
|---|---|---|---|
| num | 15 | 15 | 15 |
if [ condition ]; then # commands if true else # commands if false fi Checks condition once. Runs THEN block if true. Runs ELSE block if false. Ends after one branch runs.