Here is simple bash script which creates an simple options selection menu using bash 'select' statement, fee free to modify/copy and use this script to suite your requirement.
Continue Reading...
$ cat select.sh
#!/bin/bash
# Selection menu items goes here
SELECTION="option1 option2 option3 quit"
select options in $SELECTION; do
# here using the if statements you can perform the required operation
if [ "$options" = "option1" ]; then
echo "You have selected $options"
elif [ "$options" = "option2" ]; then
echo "You have selected $options"
elif [ "$options" = "option3" ]; then
echo "You have selected $options"
elif [ "$options" = "quit" ]; then
echo "You have selected $options"
exit
# if something else is selected, show the menu again
else
clear;
echo "please select some options"
fi
done
#!/bin/bash
# Selection menu items goes here
SELECTION="option1 option2 option3 quit"
select options in $SELECTION; do
# here using the if statements you can perform the required operation
if [ "$options" = "option1" ]; then
echo "You have selected $options"
elif [ "$options" = "option2" ]; then
echo "You have selected $options"
elif [ "$options" = "option3" ]; then
echo "You have selected $options"
elif [ "$options" = "quit" ]; then
echo "You have selected $options"
exit
# if something else is selected, show the menu again
else
clear;
echo "please select some options"
fi
done
0 comments:
Post a Comment