Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 1: Write a complete sed script in linux. ** I have the letter.txt file, but I'm not sure how to create the sed script

Question 1: Write a complete sed script in linux.

** I have the letter.txt file, but I'm not sure how to create the sed script in linux as stated in the instructions. Please help

image text in transcribed

***If you could show how to create the sed script as stated below

image text in transcribed

image text in transcribed

Code in linux terminal so far(#1 preprocessing a-d):

$ cat letter.txt

ABC Corp 1234 7 Oaks Lane Denton; TX 76509-4321 682 543-7890

February 7th 2021

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

$ sed 's/682/800/' letter.txt

$ sed 's|[(),]||g' letter.txt

$ sed 's/\/&-/' letter.txt

$ sed 's/\/&-/' letter.txt

$ sed 's/4321/1234/' letter.txt

b) A company has a set of letters that need to be modified. As an example 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, 2021 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 minori.sed that will modify the company's letters in the following ways. Note that this letter is an example. Your program will be tested against several similar letters. Note that spacing may be different in each letter. 1. Preprocessing: a. Change the area code of the phone number in the heading to 800. b. Remove the parentheses from each phone number. C. Add a dash between the area code and the rest of the phone number. (i.e. 789 123-4567 would become 789-123-4567) d. 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. e. Change Lois' last name from Lane to Kent, since she became married. f. Change Lane in the addresses to Ln. 2. Transposition (i.e., rearrange the order of individual characters): a. Swap the area code and exchange for the phone number in the body of the letter. 3. Substitution (i.e., replace characters by other characters): a. Substitute '#' for '@' to correct a type where '@' were used instead of # and change ;' to ',' to correct the typos in the addresses. 4. Append extra data: a. 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 the example, your 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, 2021 Ms. Sue Jones 1515 Mockingbird In 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. b) A company has a set of letters that need to be modified. As an example 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, 2021 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 minori.sed that will modify the company's letters in the following ways. Note that this letter is an example. Your program will be tested against several similar letters. Note that spacing may be different in each letter. 1. Preprocessing: a. Change the area code of the phone number in the heading to 800. b. Remove the parentheses from each phone number. C. Add a dash between the area code and the rest of the phone number. (i.e. 789 123-4567 would become 789-123-4567) d. 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. e. Change Lois' last name from Lane to Kent, since she became married. f. Change Lane in the addresses to Ln. 2. Transposition (i.e., rearrange the order of individual characters): a. Swap the area code and exchange for the phone number in the body of the letter. 3. Substitution (i.e., replace characters by other characters): a. Substitute '#' for '@' to correct a type where '@' were used instead of # and change ;' to ',' to correct the typos in the addresses. 4. Append extra data: a. 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 the example, your 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, 2021 Ms. Sue Jones 1515 Mockingbird In 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Distributed Relational Database Architecture Connectivity Guide

Authors: Teresa Hopper

4th Edition

0133983064, 978-0133983067

More Books

Students also viewed these Databases questions