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

Find and replace with sed command in Linux

Find and replace feature is always handy. It can turn into a torture when it comes to change or delete a simple constant string in a text file. There is a handy tool in linux for doing these kind of tihngs. Actually sed is not a text editor but it is used outside of the text file to make changes.