Return to Snippet

Revision: 7840
at August 16, 2008 19:48 by rwczippy


Updated Code
#!/bin/sh
echo "Use one of the following options"
echo "	d : run date command"
echo "	<?> : <another thing to do ...>"
echo "	q: quit this menu"
echo "enter your choice or type "q" to quit : \c"
read option
while [ "$option" != "q" ]
	do
		case $option in
			d ) date
			shift
			echo "enter your choice or type "q" to quit : \c"
			read option
			;;
			<?> ) <another command...>
			shift
			echo "enter your choice or type "q" to quit : \c"
			read option
			;;
			
#                       ...


			* )
			echo "invalid choice!"
			shift
			echo "enter your choice or type "q" to quit : \c"
			read option
			;;
			q ) exit 0
			;;
		esac
done
exit 0

Revision: 7839
at August 16, 2008 19:30 by rwczippy


Initial Code
#!/bin/sh
echo "Use one of the following options"
echo "	d: display todays date and current time"
echo "	l: list files in the present working directory"
echo "	w: see who's logged in"
echo "	q: quit this program"
echo "Enter your option and hit <enter> or type "q" to quit : \c"
read option
while [ "$option" != "q" ]
	do
		case $option in
			d ) date
			shift
			echo "Enter your option and hit <enter> or type "q" to quit : \c"
			read option
			;;
			l ) ls
			shift
			echo "Enter your option and hit <enter> or type "q" to quit : \c"
			read option
			;;
			w ) who
			shift
			echo "Enter your option and hit <enter> or type "q" to quit : \c"
			read option
			;;
			* )
			echo "invalid choice!"
			shift
			echo "Enter your option and hit <enter> or type "q" to quit : \c"
			read option
			;;
			q ) exit 0
			;;
		esac
done

exit 0

Initial URL


Initial Description
menu will only quit when 'q' is pressed

Initial Title
shell script menu

Initial Tags
Bash, script

Initial Language
Bash