My script is as follows
Expand|Select|Wrap|Line Numbers
- #!/bin/bash
- # A menu driven Shell script which has following options
- # Contents of /etc/passwd
- # List of users currently logged
- # Simple Calculator
- # Exit
- # As per option do the job
- while :
- do
- clear
- echo " M A I N - M E N U"
- echo "1. Contents of /etc/passwd"
- echo "2. List of users currently logged"
- echo "3. Simple Calculator"
- echo "4. Exit"
- echo -n "Please enter option [1 - 4]"
- read opt
- case $opt in
- 1) echo "************ Conents of /etc/passwd *************";
- more /etc/passwd;;
- 2) echo "*********** List of users currently logged";
- who | more;;
- 3) a=$1
- op="$2"
- b=$3
- if [ $# -lt 3 ]
- then
- echo "$0 num1 opr num2"
- echo "opr can be +, -, / , x"
- exit 1
- fi
- case "$op" in
- +) echo $(( $a + $b ));;
- -) echo $(( $a - $b ));;
- /) echo $(( $a / $b ));;
- x) echo $(( $a * $b ));;
- *) echo "Error ";;
- esac
- echo "Press [enter] key to continue. . .";
- read enterKey;;
- 4) echo "Bye $USER";
- exit 1;;
- *) echo "$opt is an invaild option. Please select option between 1-4 only";
- echo "Press [enter] key to continue. . .";
- read enterKey;;
- esac
- done