This script will work in all linux/unix operating systems like Redhat, Fedora, Centos, Solaris, Ubuntu, Debian etc, if they are having bash shell or sh.
See the example given below :
#!/bin/bash
PS3='Enter the choice:'
LIST="Choice1 Choice2 Choice3 Quit"
select i in $LIST
do
if [ "$i" = Choice1 ]
then
echo "Your choice is: $i"
# break
elif [ "$i" = Choice2 ]
then
echo "Your choice is: $i"
# break
elif [ "$i" = Choice3 ]
See the example given below :
#!/bin/bash
PS3='Enter the choice:'
LIST="Choice1 Choice2 Choice3 Quit"
select i in $LIST
do
if [ "$i" = Choice1 ]
then
echo "Your choice is: $i"
# break
elif [ "$i" = Choice2 ]
then
echo "Your choice is: $i"
# break
elif [ "$i" = Choice3 ]
then
echo "Your choice is $i"
# break
elif [ "$i" = Quit ]
then
exit
fi
done
echo "Your choice is $i"
# break
elif [ "$i" = Quit ]
then
exit
fi
done
No comments:
Post a Comment