O'Reilly logo

Linux and Unix Shell Programming by David Tansley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

18.9. Menus

When creating menus, the null command comes in very handy with the while loop. A while and null combined mean loop forever, which is what we want for a menu, unless of course the user selects exit or a valid option.

To create a menu you need only a while loop and a case statement to catch all the patterns the user inputs. If an invalid input is given then sound the bell, echo a error message and then carry on with the loop until the user has finished his processing and selected the exit option.

A menu should also be friendly; the user should not have to guess what to do. The main screen would also look good with the hostname and date on it, coupled with the name of the user who is running the menu. For our test purposes, all the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required