Create a Menu that provides the following functionality: 1. Allows users to sele
ID: 3766124 • Letter: C
Question
Create a Menu that provides the following functionality:
1. Allows users to select from 6 different choices including:
a. Display the current date and time.
b. List all of the files along with the size of the file in the user's home directory
c. List the last 5 lines of a file in the user's home directory. Note: the user should be prompted for the name of the file.
d. Prompt the user for his/her favorite color. When prompted for this a sub-menu should provide a list of up to 8 colors to choose.
e. One more additional menu selection to be fully implemented by the developer of his/her choice. f. Exit the program
2. Each menu should be separated into functions where appropriate.
3. The selections should be cleared between menu selections making the screen neat and well-organized.
4. When possible, separate functions should be called for each of the menu functionality.
5. A looping structure should be used to ensure the script will run until the user exits the system.
You should submit both your code, and your word or PDF document with screen captures showing your results of running your code.
Your document should be well-organized, well-written with minimal spelling and grammatical errors. The document should include page numbers, figure titles and numbers and section titles as appropriate.
Your code should include comments describing the code and header comments with your name, date and purpose of the script.
Explanation / Answer
Time(){
echo -e "The current date and time is : "
date
}
File()
{
echo -e "The file and size of each fie in the current directory are "
ls -s
}
readFile()
{
echo -n "Enter File Name : "
read file
# make sure file exits for reading
if [ ! -f $file ]; then
echo "Filename $file does not exists"
exit 1
fi
# display last five lines of the file using tail command
echo -e "The last five lines of $file are "
tail -5 $file
}
color()
{
echo -e "Choose your color from the listed colors"
echo -e "Red Blue White Green Yellow Violet Black Orange Indigo "
read color
echo -e "your favorite color is $color "
}
echo -e "a) Display the current date and time "
echo -e "b) List all the files along with the size of the file in the user's home directory "
echo -e "c)List the last 5 lines of a file in the user's home directory "
echo -e "d)Enter your favorite color "
echo -e "e)List all files and their authors"
echo -e "f)Exit the program"
echo -e "Enter your choice"
read choice
echo -e "You entered: $choice "
case "$choice" in
"a")
Time
;;
"b")
File
;;
"c")
readFile
;;
"d")
color
;;
"e")
ls --author
;;
"f")
a=1
clear
esac