Question: UNIX Shell Programming For this exercise you need to manipulate your personal contacts file to find out people whose birthday is today. Hint: consider using

UNIX Shell Programming

For this exercise you need to manipulate your personal contacts file to find out people whose birthday is today. Hint: consider using grep, sort

You are required to write a script titled searchcontacts.sh that will do the following:

  1. The script is going to take as parameters the user's full name: first name, last name.
  2. Greet the user by his or her first name.
  3. Tell the user the day of the week, and the current time in nonmilitary time. The output should resemble the following (See man pages for the time/date commands):

Today is Tuesday and the current time is 04:07:38 PM.

  1. Show the contacts whose birthday is today (hint: look at man pages for date options, then use pipes and grep):

These contacts are having a birthday today:

Xxx .

  1. Ask the user for a friends last name (you may add this as a menu option)

Enter a contact last name to search in file:

  1. Search in the file mycontacts.txt (format is shown below) for that last name and print out to the screen the line with the information about that person
  2. If not found,
    1. Count the number of lines and tell the user that in the screen
    2. Sort the file (by name) and print out to the Console the contents of the mycontacts.txt file (hint: remember commands for sorting)
  3. Tell the user (use first name) good-bye and the current hour. Exit the script.

Mycontacts.txt format:

The information is in one line and separated by spaces,

1. friend's full name: first, last.

2. his/her birth date (dd-mm)

3. his/her phone number (xxx-yyy-yyyy)

4. his/her email (name@domain.xyz)

e.g. John Smith 02-05 213-662-3577 smith@example.com

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!