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

UNIX Consider the file named data3 as shown below: XiaoLi,lxiao,lxiao@unc.edu,67

ID: 3735850 • Letter: U

Question

UNIX

Consider the file named data3 as shown below:

XiaoLi,lxiao,lxiao@unc.edu,6705462234,Jackson,NC764

NatkinPook,wnatkin,wnatkin@vcu.edu,8044344528,Salem,VA22345

EliziMoe,emoe,emoe@ncsu.edu,5208534566,Tempe,AZ85282

MaTa,mta,mta@yahoo.com,4345667345,Austin,TX91030

DianaCheng,dcheng,dcheng@asu.edu,5203456789,Matitsi,WY4587

JacksonFive,jfive,jfive@ncsu.edu,5206564573,Kyenta,AZ85483

AdiSrikanthReddy,sadi1,sadi1@asu.edu,6578904566,Wyo,WS67854

The format is: firstNamelastName,userID@email,phoneNumber,city,state,zipCode

Write a awk script called Lab4B.4.awk that will display the data in the following tab delimited format:

FirstName LastName PhoneNumber UserID@Email State Zip In addition to his the phone number must be formatted in the following format: (###)###-####

Explanation / Answer

Create a File name Sample and put your input.

Run the below command

cat Sample | awk -F',' '{print $1 " " $2 " " "(" substr($4,1,3) ")" substr($4,4,3) "-" substr($4,7,4) " " $3 " " $5 " " $6 " " $7}'

Output:

[Chapter]$ cat Sample
XiaoLi,lxiao,lxiao@unc.edu,6705462234,Jackson,NC764
NatkinPook,wnatkin,wnatkin@vcu.edu,8044344528,Salem,VA22345
EliziMoe,emoe,emoe@ncsu.edu,5208534566,Tempe,AZ85282
MaTa,mta,mta@yahoo.com,4345667345,Austin,TX91030
DianaCheng,dcheng,dcheng@asu.edu,5203456789,Matitsi,WY4587
JacksonFive,jfive,jfive@ncsu.edu,5206564573,Kyenta,AZ85483
AdiSrikanthReddy,sadi1,sadi1@asu.edu,6578904566,Wyo,WS67854

Final Output:

[Chapter]$ cat File | awk -F',' '{print $1 " " $2 " " "(" substr($4,1,3) ")" substr($4,4,3) "-" substr($4,7,4) " " $3 " " $5 " " $6 " " $7}'
XiaoLi lxiao (670)546-2234 lxiao@unc.edu Jackson NC764
NatkinPook wnatkin (804)434-4528 wnatkin@vcu.edu Salem VA22345
EliziMoe emoe (520)853-4566 emoe@ncsu.edu Tempe AZ85282
MaTa mta (434)566-7345 mta@yahoo.com Austin TX91030
DianaCheng dcheng (520)345-6789 dcheng@asu.edu Matitsi WY4587
JacksonFive jfive (520)656-4573 jfive@ncsu.edu Kyenta AZ85483
AdiSrikanthReddy sadi1 (657)890-4566 sadi1@asu.edu Wyo WS67854