Script No .
Definition:
Write a shell script that displays the following menu
▪ List homedirectory
▪ Date
▪ Print workingdirectory
▪ Users loggedin
Read the proper choice. Execute corresponding command. Check for invalid choice.
Script:
clear
echo M E N U
echo 1: List contents of homedirectory
echo 2: Date
echo 3: Print working Directory
echo 4: Users logged in
echo 5: Exists
echo Enter your choice
read ch
case $ch in
1) ls $HOME;;
2) date;;
3) pwd;;
4) who;;
5) exit;;
*) echo Invalid choise;;
Esac
OR
echo "1. List home directory"
echo "2. Date"
echo "3. Print working directory"
echo "4. Users logged in "
echo "Enter your choice"
read ch
case $ch in
1) echo "Home directory is $HOME";;
2) echo "Todays date is `date`";;
3) echo "Present working directory is`pwd`";;
4) echo "No of users logged in are "
who | wc -l;;
*) echo "Invalid choice"
esac
OR
echo "
1. List home directory
2. Date
3. Print working directory
4. Users logged in"
read c
case $c in
1) ls /home;;
2) date;;
3) pwd;;
4) who am i;;
*) echo "Invalid Choice";;
esac