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

Linux 1

The document provides a shell script that offers a menu-driven interface for users to display a directory, create a file, display logged-in users, or terminate the program. It includes functions for each menu option and a loop to continuously prompt the user until they choose to exit. The script contains some formatting and syntax errors that need correction for proper functionality.

Uploaded by

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

Linux 1

The document provides a shell script that offers a menu-driven interface for users to display a directory, create a file, display logged-in users, or terminate the program. It includes functions for each menu option and a loop to continuously prompt the user until they choose to exit. The script contains some formatting and syntax errors that need correction for proper functionality.

Uploaded by

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

Powered by AI

Bing

I can try to write a shell script for [Link] is one possible solution:

#!/bin/
#A shell script to display a menu driven facility
#Define a function to display the menu options
display_menu(){
echo "P ease sel c an tio n
l e t from the menu:"
ech o "1 Display a direocptor y"
echo "[Link] a file"
echo "[Link] the logged in users"
echo "[Link] the program"
echo "Enter your choice:
}

#Define a function to display a directory


display_dir(){
echo "Enter the name of the directory:"
read dir
if [-d "$dir " ]; then
echo "The contents of $dir are:"
ls "$dir"
else
echo "sdir is not a valid directory"
?
fi
#Define a function to create a file
create_file (){
echo "Enter the name of the file:"
a -f "$file" ]; then
ile
echo "$file already exists"
else
touch
echo "Sfile created successfully"
}
fi
#Define a function to display the logged in users
display_users(){
echo "The logged in users are:"
who
}

#Define a function to terminate the program


terminate(){
echo "Thank you for using this [Link]!"
exit O
}

#Define a loop to display the menu and execute the user's choice
while true;do
display_menu
read choice
case $choice i n
1)display_dir ;;
2)create_file ;;
3)display_users ;;
4)terminate ;;
*) echo "Invalid [Link] try again.";;
esac
echo "Press any key to continue..."
read
done

I hope this helps you with your task.

You might also like