0% found this document useful (0 votes)
7 views3 pages

Shell Script Menu for System Info

The document provides a shell script that displays a menu with options to list the home directory, show the date, print the working directory, and display users logged in. It reads the user's choice and executes the corresponding command, while also handling invalid choices. Multiple variations of the script are presented, demonstrating different ways to implement the menu and commands.

Uploaded by

for11trade
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views3 pages

Shell Script Menu for System Info

The document provides a shell script that displays a menu with options to list the home directory, show the date, print the working directory, and display users logged in. It reads the user's choice and executes the corresponding command, while also handling invalid choices. Multiple variations of the script are presented, demonstrating different ways to implement the menu and commands.

Uploaded by

for11trade
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

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

You might also like