Question
UNIX Shell Script Using vi, create a data file called .addr_book in your home directory. This file is a book of contacts and should contain
UNIX Shell Script
Using vi, create a data file called ".addr_book" in your home directory. This file is a book of contacts and should contain entries for people, businesses, etc. For example you might have an entry for me: Jane Doe - Unix/Linux Instructor - email: janedoe@someschool.edu Note that each entry is a single line! Have at least 3 entries in the file. (Don't have any blank lines or any comment lines.) Here is another example using generic information: Firstname Lastname - jobtitle - email: lastname.firstname@emailserver.com
Start a session log with the script command for your command line work. You can type exit before using interactive utilities, like vi, but remember to restart your session log when you leave vi.
Use utilities to search for entries in your .addr_book file and display them. For example, one command could lookup my entry and display it, then another command could lookup your entry and display it.
If you don't already have one, create a "bin" directory within your home directory
Create an empty file in your bin directory called "lookup" and make it executable with appropriate permissions (so you can view or modify or execute your script).
Using vi, edit the file called "lookup" that you created in step 6. You will use positional parameters in this script, so make sure to review chapter 25 in the online textbook for this step. The script should perform the following tasks:
Display a message such as "Searching for" then display the positional parameter(s) provided when the script is executed.
Using positional parameters, find the entry in the "$HOME/.addr_book" file that matches the positional parameter(s) provided when the script is executed.
Then, display a message such as "All Address Book Entries: "
Display all lines from the file in sorted order. The output MUST be sorted. You can sort the entire line, you are not required to sort on any specific part of the line. However, if you would like an extra challenge, try sorting on the last name.
The output of the lookup script might look something like this when the positional parameter "Meade" is used when the script executes (two entries in the file are shown in this example):
Searching for Meade...
Jane Doe - Unix/Linux Instructor - email: janedoe@someschool.edu
All Address Book Entries:
Firstname Lastname - jobtitle - email: lastname.firstname@emailserver.com
Jane Doe - Unix/Linux Instructor - email: janedoe@someschool.edu
(HINT: use grep and sort)
Add creative extras if you wish.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started