Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 0 3 ( 3 0 points ) Task 0 4 ( 4 0 points ) Write an interactive Bash script that manages a collection

Task 03(30 points) Task 04(40 points)
Write an interactive Bash script that manages a collection of books. The script takes no
command line arguments, instead, the user enters the program and then enters commands
within it that are read as input. Use a loop so the user can keep trying commands until they exit.
The books must be stored in an array named books.
The following internal commands must be supported:
add [book_name]
Adds a book to the collection.
Calls a function that you create named add_book() which adds the book
to the array and displays a confirmation message.
remove [book_name]
Removes a book from the collection.
Calls a function that you create named remove_book() which removes the
book from the array and displays a confirmation message.
list
Lists all of the books in the collection.
Calls a function that you create named list_books() which displays all of
the books in the collection.
help
Displays a message to the user with a hint as to how the command should be run
(sample syntax of the command usage).
exit
Exits the script.
You must use a case statement in your script to make the decision on which function to run. The
help and exit commands do not have to be implemented as functions, but you may choose to do
so if you wish.
An error message should be displayed if the user enters no command or an invalid command
and it should tell them how to get help (using the option above).
Write a Bash script that takes one command line argument. The argument should specify the
type of system information to display. The following command line arguments must be
supported:
cpu
Display information about the CPU
Command to use in your script: Iscpu
Important: You must limit the output using awk to only match what
is displayed in the screenshots below for this option.
memory
Display information about the memory
Command to use in your script: free -h
disk
Display information about the disk usage
Command to use in your script: df -h
all
Displays all of the above. Using all of the same commands.
You must use a case statement in your script to make the decision on which command to run.
In addition, if the script is run with no arguments provided, it should display a message to the
user with a hint as to how the command should be run (sample syntax of the command usage).
An error message should be displayed if the user enters an invalid argument.
Provide labels for the type of information being displayed before you display it as shown in the
screenshots below.
Here are screenshots of the expected behavior, testing all scenarios described above:
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions