Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please don\'t copy paste from another answer you Googled. The answer that is cur

ID: 3866836 • Letter: P

Question

Please don't copy paste from another answer you Googled. The answer that is currently out there does not work.

In Unix, write an awk program, called lab6.awk, to process the data below:

Consider the data below, stored in a file called rawaddresses. It was made up by the students. But it is the type of raw data IT professionals are often asked to process.

The data consists of, in order: full name, 9-digit student ID, email address, 10-digit phone number, 2- uppercase letters state code, optional street number, optional direction, street name, city, and 5-digit zip code.

The full name consists of first name that starts with uppercase character, either a middle initial (in uppercase, no dot after) or a middle name (starts with uppercase letter) or no middle, and a last name (starts with uppercase letter).

The street direction, when provided, is an uppercase letter.

The street names and city names all start with uppercase letter. It can be assumed that city names are all a single word; but street names could have multiple words, each starting with uppercase letters or a digit (eg. 5th St).

Ryan:Wehe:989987412:rwehe@asu.edu:2025550126:CO:2001:Blake:St:Denver:80205

Joseph:Lee:605497184:josephl@mailinator.com:3035550103:CO:5986:Budweiser:Way:Alamosa:81101

Amy:Johnson:783333251:amyj@mailinator.com:6515550164:MN:14N:5th:St:Minneapolis:55403

Daniel:JEverhard:314849866:everhard@asu.edu:5059358554:NM:8830:Johnson:Rd:Albuquerque:87122

Philip:EPeterson:325764011:peterson@asu.edu:4561238888:WA:54246:8th:Ave:Lacey:98513

Matt:VNulk:124085733:nulk@asu.edu:2093865442:KS:1234:Manhattan:St:Riley:87512

Brandon:TLyons:123456123:btlyons1@asu.edu:5755595459:AZ:635:WElm:St:Mesa:85212

Roger:ATurtle:983421567:rat@btlyons.com:8587754321:IA:3400:SW:IslanD:rdDesmoines:50021

Marc:JWhiz:745629754:marcwhiz76@yahoo.com:6195323200:CA:215:N:CollegeGroveWay:Sandiego:9120

Write an awk program, called lab6.awk, to process the above data and present in the format below (store the output in a file called addressbook):

Ryan Wehe, 989-98-7412

2001 Blake St

Denver, CO 80205

wehe@asu.edu

(202) 555-0126

Joseph Lee, 605-49-7184

5986 Budweiser Way

Alamosa, CO 81101

josephl@mailinator.com

(303) 555-0103

AmyJohnson, 783-33-3251

14 N 5th St

Minneapolis, MN 55403

amyj@mailinator.com

(651) 555-0164

etc.

Explanation / Answer

Code:

#!/usr/bin/awk -f

# script name: lab6i_1.awk

BEGIN{

FS=":";

}

{

fullName = $1 " " $2;

studentId = substr($3, 1,3) "-" substr($3, 4,2) "-" substr($3, 6);

email = $4;

phoneNumber = substr($5, 1, 3) ") " substr($5, 4,3) "-" substr($5, 7);

stateCode = $6;

opt_street_num = $7;

opt_direction = $8;

streetName = $9;

city = $10;

zipCode = $11;

print fullName "," studentId;

print opt_street_num " " opt_direction " " streetName;

print city ", " stateCode " " zipCode;

print email;

print phoneNumber;

print " ";

}

Input file:

Unix Terminal> cat raw_address

Ryan:Wehe:989987412:rwehe@asu.edu:2025550126:CO:2001:Blake:St:Denver:80205

Joseph:Lee:605497184:josephl@mailinator.com:3035550103:CO:5986:Budweiser:Way:Alamosa:81101

Amy:Johnson:783333251:amyj@mailinator.com:6515550164:MN:14N:5th:St:Minneapolis:55403

Daniel:JEverhard:314849866:everhard@asu.edu:5059358554:NM:8830:Johnson:Rd:Albuquerque:87122

Philip:EPeterson:325764011:peterson@asu.edu:4561238888:WA:54246:8th:Ave:Lacey:98513

Matt:VNulk:124085733:nulk@asu.edu:2093865442:KS:1234:Manhattan:St:Riley:87512

Brandon:TLyons:123456123:btlyons1@asu.edu:5755595459:AZ:635:WElm:St:Mesa:85212

Roger:ATurtle:983421567:rat@btlyons.com:8587754321:IA:3400:SW:IslanD:rdDesmoines:50021

Marc:JWhiz:745629754:marcwhiz76@yahoo.com:6195323200:CA:215:N:CollegeGroveWay:Sandiego:912

Code output screenshot:

https://pasteboard.co/GEuEtIq.png