bash select menu example
Here is a simple bash select menu example:
(Thanks to my friend)
(Thanks to my friend)
#!/bin/bash
# Date: 15.04.08
# Author: bash@roshankarki.com.mnp
# Purpose: Usage of select
PS3='Please enter your choice'
LIST="choice1 choice2 END"
select OPT in $LIST
do
if [ $OPT = "choice1" ] &> /dev/null
then
echo you chose choice1
elif [ $OPT = "choice2" ] &> /dev/null
then
echo you chose choice2
elif [ $OPT = "END" ] &> /dev/null
then
exit 0
fi
done
#END
very useful. It saves our time.
ReplyDeleteThis doesn't work. Why do you post incorrect examples?
ReplyDeleteI'm astonished by your comment. Can you specify what makes you think this doesn't work or can you provide the error if you have tried it in bash.
ReplyDeleteI did one bash men script with cat
ReplyDeletehttp://unstableme.blogspot.com/2008/06/bash-script-menu.html
// Jadu
Thank you very much. The select opt in $list;do;done method is very easy to implement.
ReplyDeleteThis works just fine. Thank You
ReplyDelete