Tuesday, April 15, 2008

bash select menu example

Here is a simple bash select menu example:
(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

No comments:

Post a Comment