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

Please answer p1, p2, p3 using sed command Consider the address book below: $ ca

ID: 3821528 • Letter: P

Question

Please answer p1, p2, p3 using sed 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

p1) Print the lines with imap number in the email address.

p2) Print the lines that end with valid zip code

p3) Print the lines that end with invalid zip code

Explanation / Answer

Unix commands

1) Command : # sed -n /PATTERN/p filename
Answer for problem : # sed -n /imap/p addr

2)valid zip code (5 digit)
Answer : sed -e '^[A-Z]d{5}?$' addr
If the zip code contains valid numbers and alphabets then it will show valid

3)invalid zip code (5 digit)
Answer : sed -e '/^([A-Z]d{5}?)$/s' addr
If the zip code contains greater than 5 digits and small alphabets then it will show as invalid