#!/bin/bash # This file uses the until statment to create a simple menu # to prompt user for a selection. The selection 6 will exit # the menu (script) - error checking for invalid numbers # is not present (see until_2) # Notice std error from test command redirected # to /dev/null - try to press ENTER num=1 until [ $num = 6 ] 2> /dev/null # Prevents "test errors" do printf "\n\t\tMENU\n" printf "\t1. Add a File\n\t2. Change a File\n\t3. Delete a File\n" printf "\t4. Print a File\n\t5. Update Records\n\t6. Exit\n\n" printf "\tPlease make a selection >> " # Notice how selection is read BEFORE error checking read num while [ $num -lt 1 -o $num -gt 6 ] 2> /dev/null # prevent "test error" do echo echo -n "Invalid Number - Please Re-enter >> " read num done done