Quantcast
Channel: UNIX and Linux Forums
Viewing all articles
Browse latest Browse all 16232

Simple bash script menu

$
0
0
Dear Sir,

May I know how do I go about adding the following feature into the script below:

When user enter values other than 1,2,3,4,

a) Message “Wrong entry !!! Pls select 1,2,3 or 4” is displayed
b) The screen is cleared again and the menu is displayed.


Code:

#!/bin/bash
clear
var=1
until [ $var -eq 4 ]
do
echo "Menu"
echo "(1) Item 1"
echo "(2) Item 2"
echo "(3) Item 3"
echo "(4) Exit"
read -p "Enter your choice " var
clear
echo "Your choice is $var"
done

I've tried adding * but it returns an syntax error.

Thank you.

Viewing all articles
Browse latest Browse all 16232

Trending Articles