The short form of the if statement, which must be typed on one line, dispenses with the then keyword and accepts a single statement to be executed if expr evaluates as true.
The long form uses a then keyword and allows optional else and elif clauses. The last if in an elif chain may be either a short- or a long-form if statement.
Where an expression is expected, conventional high level language syntax is accepted. Names refer to variables, * means multiply, not wildcard and > means greater than, not i/o redirection.
In a switch statement, expressions are compared by pattern match, as if using the =~ comparison operator. The case expression can be a string with wildcard characters. Comparisons are made down the list of alternatives until one matches. All following statements are executed until a break is encountered. A default clause is optional but is always satisfied if no other case matches.
Statement relationships
Expression operators
Wildcard characters
Tutorial: if and switch
Tutorial: Programming constructs
Tutorial: Expressions
Tutorial: Wildcarding