Moving onto where we require a greater degree of control, we can use the elif
keyword. Unlike else
, elif
requires an additional condition to be tested for each elif
. In this way, we can provide for different circumstances. We can add in as many elif
conditions as required. The following shows a pseudo-code:
if condition; then statement elif condition; then statement else statement fi exit 0
A script may make life easier for the operator by providing a simplified selection for a more complex code. Even though the script becomes gradually more complex to meet the requirements, to the operator the execution is greatly simplified. It is our job to enable users to run more complex operations easily from the command line when creating scripts. Often, this will necessitate the addition of more complexity to our scripts; however, we will be rewarded with the reliability of the scripted application.