Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
The most common way to create an interactive shell script is to utilize a menu. Offering your customers a choice of various options helps guide them through exactly what the script can and can't do.
Menu scripts usually clear the display area, and then show a list of options available. The customer can select an option by pressing an associated letter or number assigned to each option. Figure 17.1 shows the layout of a sample menu.
Figure 17.1 Displaying a menu from a shell script
The core of a shell script menu is the case command (see Chapter 11). The case command performs specific commands, depending on what character your customer selects from the menu.
The following sections walk you through the steps you should follow to create a menu-based shell script.