In addition to interactivity, it can also be very beneficial to add control structures to your shell scripts. Our scripts, to this point, have executed straight through from beginning to end. This works fine, but what if we need the script to make some decisions? Based on user input or output from a command, you may want the script to determine a course of action. This is done by implementing control structures in the script. We’re going to discuss the following about this type of script element:
• Using if/then/else structures
• Using case structures
• Using looping structures
Let’s begin by reviewing if/then statements.
Using an if/then/else structure within your shell script gives ...