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

In need of some help with Linux/UNIX shell scripting using the awk command: Cons

ID: 3792798 • Letter: I

Question

In need of some help with Linux/UNIX shell scripting using the awk command:

Consider the address book below:

$ cat addr

Xiao Li, lxiao@unc.edu, 6705462234, Jackson, NC 764
Natkin William, wnatkin@imap28.vcu.edu, 8044344528, Richmond, VA 22345 Elizi Moe, emoe@ncsu.edu, 5208534566, Tempe, AZ 85282
Ma Ta, mta@yahoo.com, 4345667345, Austin, TX 91030
Diana Cheng, dcheng@asu.edu, 5203456789, Matitsi, WY 4587
Jackson Five, jfive@ncsu.edu, 5206564573, Kyenta, AZ 85483
Adi SrikanthReddy, sadi1@imap1.asu.edu, 6578904566, Wyo, WS 67854

Using awk, please write a script called activity5.3-4.awk to print the full name, Email Address, state and zip for those with an “imap” email. Be sure to use multi-line statements for improved readability. Include the header identifying each field, and a footer indicating the end of listing.

Explanation / Answer

>> awk -F "," '{if (match ($2, /' "{@imap}" '/)) {print $1, $2, $4, $5}}' activity5.3-4.awk

-F is used to set the field separator.

"match" is used to find the required substring, here @imap.

After checking, we are printing all the required fields.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote