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

Need help with shell scripting and using the sed command in Linux/Unix Consider

ID: 3817677 • Letter: N

Question

Need help with shell scripting and using the sed command in Linux/Unix

Consider the address book below:

$ cat addr

Xiao Li, lxiao@unc.edu, 6705462234, Jackson, NC 764

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 Srikanth Reddy, sadi1@imap1.asu.edu, 6578904566, Wyo, WS 67854

Natkin William, wnatkin@imap28.asu.edu, 8044344528, Richmond, VA 22345

Provide the sed command to:

Substitute the 3rd occurrence of “asu” in email address with “vcu”.

Remove all imap and imap number from the email addresses

Add the string “School Email” next to all email addresses ending with “.edu”

Move the email addresses to the end of the lines

Explanation / Answer

Substitute the 3rd occurrence of “asu” in email address with “vcu”.

sed ':a;N;$!ba;s/asu/vcu/3' addr

Remove all imap and imap number from the email addresses

sed -e 's/<imap*[0-9][0-9]>//g' addr | sed -e 's/<imap*[0-9]>//g'

Add the string “School Email” next to all email addresses ending with “.edu”

sed 's/.edu/& School Email/' addr

Move the email addresses to the end of the lines

sed -r "s/^([^,]+)(,[^,]+)(.*)//g" addr

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