August 2016
Intermediate to advanced
456 pages
11h 17m
English
This chapter introduces the conditional statement, a construct that is present in almost every programming language: 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 commandt then command command ... fi
where commandt is executed and its exit status is tested. If the exit status is zero, the commands that follow between then and fi are executed; otherwise, they’re skipped.
To understand how conditional tests work, it’s important to know about how Unix works with what’s called the exit status. Whenever any program completes execution, it returns an exit status code to the shell. ...
Read now
Unlock full access