Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a linux bash script named Merge to do a mail merge, i.e., fill in values into a form letter. You may invoke awk and/or

Write a linux bash script named Merge to do a mail merge, i.e., fill in values into a form letter. You may invoke awk and/or sed in your bash script, as needed. For example, you might have your bash script dynamically construct a sed program and execute it.

The first argument to the script should be a text file that is the template for the form letter, called the template file. Inside this file, text of the form %n for integer n indicates that this will be replaced by field number n during the merge. The second argument to the script should be a text file with fields, called the database file. Fields are separated by commas and records are separated by newline characters.

The script should produce text files in the current directory, named 1.txt, 2.txt, . . . , m.txt where m is the number of lines in the database file. File i.txt should be the template file, with fields plugged in according to record i (line number i) in the database file. If record i has fewer fields than what is required by the template, then the missing values should remain un-replaced.

For example:

user$ cat ../templ.txt

Dear %1,

Thank you for your generous donation of %2 to the re-election campaign of your politician. Rest assured: politician is very committed to %3 and will not rest until this is achieved.

Remember to vote on November 6!

user$ cat ../data.txt

Curly,$50,rebuilding infrastructure

Moe,$15,destroying infrastructure

Larry,$2,raising taxes

Shemp,10 cents,lowering taxes

Joe,string

user$ Merge ../templ.txt ../data.txt

user$ ls

1.txt 2.txt 3.txt 4.txt 5.txt

user$ cat 4.txt

Dear Shemp,

Thank you for your generous donation of 10 cents to the re-election campaign of your politician. Rest assured: politician is very committed to lowering taxes and will not rest until this is achieved.

Remember to vote on November 6!

user$ cat 5.txt

Dear Joe, Thank you for your generous donation of string to the re-election campaign of your politician. Rest assured: politician is very committed to %3 and will not rest until this is achieved.

Remember to vote on November 6!

user$

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

Database Programming With Visual Basic .NET

Authors: Carsten Thomsen

2nd Edition

1590590325, 978-1590590324

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago