8. Decisions, Decisions
In This Chapter
This chapter introduces a statement that is present in almost all programming languages: if
. It enables you to test a condition and then change the flow of program execution based on the result of the test.
The general format of the if
command is
if commandtthen command command ...fi
where commandt is executed and its exit status is tested. If the exit status is zero, the commands that follow between the then
and the fi
are executed; otherwise, they are skipped.
Exit Status
Whenever any program completes execution under ...
Get Unix Shell Programming, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.