Let's understand our script in detail:
- Creating the select_menu.sh script was trivial, but besides the use of select, some of the concepts should look familiar: functions, return, case statements, and recursion.
- The script enters the menu by calling the main_menu function and then proceeds to use select to generate a menu from the ${OPTIONS} array. The hard-coded variable named PS3 will output the prompt before the menu, and $REPLY contains the index of the item selected.
- Pressing 1 and pressing Enter will cause select to walk through the items and then execute the list_files function. This function creates a submenu by using select for the second time to list all of the files in the directory. Selecting any directory will ...