Question: In this assignment, you will write sed and gawk commands to accomplish certain requested functionality. Given the many powerful features of sed and gawk, you
In this assignment, you will write sed and gawk commands to accomplish certain requested functionality. Given the many powerful features of sed and gawk, you are provided with links to manuals and tutorials for sed and gawk to assist you in completing this assignment.
- Consider the following file called letter.txt containing a company letter:
ABC Corp
1234 7 Oaks Lane
Denton; TX 76509-4321
(682) 543-7890
February 7th, 2020
Ms. Sue Jones
1515 Mockingbird Lane
Apartment @701
Denton; TX 76509
Dear Mrs. Jones,
This letter is to inform you that you have won the super coder contest. To Claim
your winnings, you may visit our office or call our claim hotline (654) 817-4321.
Mention your claim number @687.
Sincerely,
Lois Lane
Write a complete sed script called minor1.sed that will modify the letter in the following ways:
- Preprocessing:
- Change the area code of the phone number in the heading to 800.
- Remove the parentheses from each phone number.
- Add a dash between the area code and the rest of the phone number. (i.e. 789 123-4567 would become 789-123-4567)
- Change the zip+4 code in the heading from 4321 to 1234. The zip+4 is the last 4 digits of the zip code after the dash.
- Change Lois last name from Lane to Kent, since she became married.
- Change Lane in the addresses to Ln.
- Transposition (i.e., rearrange the order of individual characters):
- Swap the area code and exchange for the phone number in the body of the letter.
- Substitution (i.e., replace characters by other characters):
- Substitute # for @ to correct a type where @ were used instead of # and change ; to , to correct the typos in the addresses.
- Append extra data:
- Append a p.s. clause after the signature (the end of the letter). It should read
p.s. your winnings must be claimed by February 29th.
In this file, for example, my sed script should print the following:
$ sed -r -f minor1.sed letter.txt
ABC Corp
1234 7 Oaks Ln
Denton, TX 76509-1234
800-543-7890
February 7th, 2020
Ms. Sue Jones
1515 Mockingbird Ln
Apartment #701
Denton, TX 76509
Dear Mrs. Jones,
This letter is to inform you that you have won the super coder contest. To Claim your winnings, you may visit our office or call our claim hotline 817-654-4321.
Mention your claim number #687.
Sincerely,
Lois Kent
p.s. your winnings must be claimed by February 29th.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
