Write a bash (or Bourne) script that manages a book library database.
The script allows a user to add books to the database, check in/out a book, display books, print sorted reports and delete books. The script should be menu-based with the following options:
Main Menu:
1) Edit Submenu
2) Report Submenu
3) Quit
Edit Submenu:
1) Add a book
2) Display a book
3) Checkin book
4) Checkout book
5) Delete a book
6) Return to Main Menu
Report Submenu:
1) Sort by Author
2) Sort by Title
3) Display all checked-out books
4) Return to Main Menu
Each book entry consists of a Title, Author, Status, Borrower's name, and Check Out date. The status of a book could be in or out. The check out date and borrower's name would be empty if the status of a book is in.
The book entries must be kept in a text file (called .books) in the user's home directory with the following format:
Oracle Programming:Sunderraman:in::
Database Systems:ElMasri
ut:12/5/99:Jones
Java Programming:King
ut:10/12/99:Smith
The title of the book serves as the primary key, i.e. we cannot have two books with the same title.
The options within the Report submenu should produce a well formatted listing of the books.
Each of the sub-options in the Edit sub-menu should interact with the user as follows:
(1) Add a book: should prompt the user for the following:
Book Title:
Author:
This option should check to see if there is a book with the same title. If present, an error message should be generated otherwise the book should be added to the database.
(2) Display a book: should prompt the user for the book title:
Book Title:
After reading the book title, this option should verify if the book exists in the database; if not, an error message should be generated; otherwise the book should be displayed in a nice format.
(3) Checkin book: should prompt the user for the book title:
Book Title:
After reading the book title, this option should verify that the book exists and that it is checked out. If so, then the status should be changed in the database, otherwise an error message should be generated.
(4) Checkout book: should prompt the user for the book title and borrower's
name:
Book Title:
Borrower:
After reading the book title and name, this option should verify that the book exists and that it is checked in. If so, the status should be changed in the database, otherwise an error message should be generated. The system date should be used to update the checkout date.
(5) Delete book: should prompt the user for the book title:
Book Title:
After reading the book title, this option should verify that the book exists and that it is not checked out. If so, then the book entry should be deleted in the database, otherwise an error message should be generated.
Each of the sub-options in the Report sub-menu should interact with the user as follows:
(1) Sort by Author: should print a well formatted listing sorted by authors' names of all the books in the database.
(2) Sort by Title: same as (a) but sorting is on title.
(3) Display all checked-out books: should print a well formatting listing of books that are in out status, in ascending order of their check-out dates.