Consider the file named data3 as shown below: XiaoLi,lxiao,lxiao@unc.edu,6705462
ID: 3735119 • Letter: C
Question
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 this the phone number must be formatted in the following format: (###)###-####
Explanation / Answer
BEGIN {
print "FirstName LastName UserID@Email PhoneNumber City State Zip"
print "________ ________ ________ ________ ________ ________ ________"
FS=","
}
{
if($4 != "") {
phone_no = "(" substr($4,1,3) ")" substr($4,4,3) "-" substr($4,7)
} else {
phone_no = ""
}
state = substr($6,1,2)
zip = substr($6,3)
print $1 " " $2 " " $3 " " phone_no " " $5 " " state " " zip
}
END {
print "The end"
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.