October 2000
Intermediate to advanced
1152 pages
26h 41m
English
Conditional statements are used in shell programs to decide which part of the program to execute depending on specified conditions.
The if statement evaluates a logical expression to make a decision. An if condition has the following format in pdksh and bash:
if [ expression ]; then Statements elif [expression ]; then Statements else Statements fi
The if conditions can be nested. That is, an if condition can contain another if condition within it. It is not necessary for an if condition to have an elif or else part. The else part is executed if none of the expressions that are specified in the if statement and are optional in subsequent elif statements are true. The word fi is used to indicate the ...
Read now
Unlock full access