Conditional Statements

Conditional statements execute if and only if a certain condition or conditions are true. They generally come in three forms: if statements, case statements, and logical AND/OR statements. These are very fundamental and useful constructs in programming; flow control depends on them (executing certain blocks of code depending on the outcome of a condition), as does the ability of a program to behave correctly upon receiving certain expected arguments (which would be handled by case statements).

if Statements

if statements test numerical expressions given in brackets (which, as you saw earlier, are a shorthand for the test command). If the test condition is true, the statements inside the if block are executed. If the condition ...

Get FreeBSD6 Unleashed now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.