Skip to main content

Simple menu for bash script

Below is simple menu for a bash script:


#!/bin/bash

command1() {
echo "command1 executed!"
read
}

command2() {
echo "command2 executed!"
read
}

while :
do
clear
echo "***************************"
echo "*            Menu                *"
echo "***************************"
echo "* [1] Command 1           *"
echo "* [2] Command 2           *"
echo "* [0] Exit                        *"
echo "***************************"
echo -n "Select your choise []: "
read choise
case $choise in
1) command1 ;;
2) command2 ;;
0) exit 1 ;;
*) echo -n "Wrong choise!!! Press Enter to continue..."; read ;;
esac
done

Comments

Popular posts from this blog