Task

Write an awk script program "myawk" which will run with an input file [input-file] as:
 awk -f myawk [input-file]
and will produce 3 output files
 file1.txt, file2.txt, file3.txt.

Input

The input file contains 7 columns of information which are First,Last,Title,Phone,E-mail,Office,Research for faculty members. The first line of the file specifies the column names separated by tabs. The order of the columns never changes. Each of the following lines contain the information about one faculty member. The information for each column is separated by a tab. However, there can be empty lines within the file which should be ignored. The information in the columns are as follows:

First: The first name of the faculty member. Can be more than 1 word. Guaranteed to be atmost 32 characters.
Last: The last name of the faculty member. Can be more than 1 word. Guaranteed to be atmost 32 characters.
Title: The title of the faculty member. It is one of "Assistant Professor","Associate Professor","Professor","Lecturer".
Phone: Telephone number of the faculty member. This will be of the form "(XXX)XXX-XXXX".
E-mail: The e-mail address of the faculty member. Guaranteed to be atmost 32 characters.
Office: The office number of the faculty member. This will be of the form "[Building],[Room]". Guaranteed to be atmost 32 characters.
Research: The research areas of the faculty member. The areas are separated by a comma. Guaranteed to be less than 256 characters.

Output

file1.txt should contain one line for each faculty member. The format of the lines will be
 [Last name],_[Initial of the first name]._[Title]_[Room number]_Ext_[Last four digits of the phone number]
where _ denotes single space. First Professors, then Associate Professors, then Assistant Professors and finally Lecturers should be listed. Within each group, the faculty members should be sorted wrt to their last names.

file2.txt should contain one line for each faculty member with a phone number. The lines should be of the form:
 [Phone number]_[First name]_[Last name]_[E-mail]
The lines should be sorted such that the phone numbers are in increasing order(considering the whole number).

file3.txt should contain lines each of which either is empty or contains a research area or a faculty name. The first line should always contain research area. Each research area which is output in the file is followed by the names of the faculty interested in it and by an empty line. The faculty names should be sorted lexicographically. Also, the file should contain all research areas mentioned in the input file and they should be sorted lexicographically. Notice that in the input the same research area can occur with different cases. The research areas should be matched without case sensitivity. It is not important how you output a research area(lowercase or uppercase).

Sample Input File(note that tabs are separating the columns)

First Last Title Phone E-mail Office Research Divyakant Agrawal Professor (805)893-4385 agrawal@cs.ucsb.edu HFH,Rm 3117 Distributed systems,distributed databases Kevin Almeroth Professor (805)893-2777 almeroth@cs.ucsb.edu HFH,Rm 2113 Computer networks,distributed systems Elizabeth Belding Associate Professor (805)893-3411 ebelding@cs.ucsb.edu HFH,Rm 2121 Mobile wireless networking Amr El Abbadi Professor (805)893-4239 amr@cs.ucsb.edu HFH,Rm 3115 Distributed databases Christopher Kruegel Assistant Professor (805)893-6198 chris@cs.ucsb.edu HFH,Room 1117 Computer security

Sample file1.txt

Agrawal, D. Professor Rm 3117 Ext 4385 Almeroth, K. Professor Rm 2113 Ext 2777 El Abbadi, A. Professor Rm 3115 Ext 4239 Belding, E. Associate Professor Rm 2121 Ext 3411 Kruegel, C. Assistant Professor Room 1117 Ext 6198

Sample file2.txt

(805)893-2777 Kevin Almeroth almeroth@cs.ucsb.edu (805)893-3411 Elizabeth Belding ebelding@cs.ucsb.edu (805)893-4239 Amr El Abbadi amr@cs.ucsb.edu (805)893-4385 Divyakant Agrawal agrawal@cs.ucsb.edu (805)893-6198 Christopher Kruegel chris@cs.ucsb.edu

Sample file3.txt

Computer networks Kevin Almeroth COMPUTER SECURITY Christopher Kruegel Distributed databases Amr El Abbadi Divyakant Agrawal Distributed systems Divyakant Agrawal Kevin Almeroth Mobile wireless networking Elizabeth Belding

Assumptions and Constraints

You may safely assume that the number of faculty members will be atmost 100.

Submission

Submit the program "myawk" through the submission system.