Question: home / study / engineering / computer science / computer science questions and answers / The Language Is Bash Create A Bash Script Called lookup

home / study / engineering / computer science / computer science questions and answers / The Language Is Bash Create A Bash Script Called "lookup" That Will Do The Following: A. Sort ...

Question: The language is bash Create a bash script called "lookup" that will do the following: a. Sort "da...

The language is bash

Create a bash script called "lookup" that will do the following:

a. Sort "datafile" by last names. (datafile is a text file i will create with first and last names and an address)

b. Show the user the contents of "datafile".

c. Tell the user the number of entries in the file and Ask the user if they would like to add a new entry to datafile

d. If the answer is y or yes then prompt the user to enter new name and address. Each variable will be stored separetly and you will append the new information into the datafile.

e. Sort the datafile by last names and Tell the user you added their entry and show them the line preceded by the line number.

check to see if the "datafile" exists and if it is readable and writable. Add a menu to the "lookup" script to resemble the following: [1] Add entry [2] Delete entry [3] View entry [4] Exit

Write a function to handle each of the items in the menu. After the user has selected a valid entry, and the function has completed, ask if the user would like to see the menu again. If an invalid entry is entered, the program should print: "Invalid entry, try again." and the menu will be redisplayed. You already have the Add entry part of the script written. The Add entry routine should now include code that will check to see if the name is already in the datafile and if it is, tell the user so. If the name is not there, add the new entry. Now write the code for the Delete entry, View entry, and Exit functions. Each 'function' should be contained inside a bash function which gets invoked upon the user selection. The Delete part of the script should first check to see if the entry exists before trying to remove it. If it does, notify the user; otherwise, remove the entry and tell the user you removed it. On exit, make sure that you use a digit to represent the appropriate exit status.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!