#!/bin/bash # This command uses the break command to break-out of a # while loop, thus terminating the menu as well as the # script. Note the if statement used to allow for the break num=1 until [ $num = 6 ] do clear 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 # if statement to intiate break if one byte is used such as # RETURN or CTRL-D instead of 2 bytes for a regular character if [ `echo $num | wc -c` = 1 ] then break fi while [ $num -lt 1 -o $num -gt 6 ] do echo echo -n "Invalid Number - Please Re-enter >>" read num done done