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

Write a bash shell script to carry out each of the following tasks: a. Mailmerge

ID: 3812441 • Letter: W

Question

Write a bash shell script to carry out each of the following tasks:

a. Mailmerge:

Suppose that you want to write the same letter to many people, except that you want each letter addressed to each recipient personally by his/her name:
1. In Windows, use Notepad to create a simple text file containing the letter template which contains NAME wherever you want the person's name to appear in the letter.

2. Transfer this file to the Linux system.

3. In Linux, create a names file which contains the names of the letter recipients (one per line).

4. In Linux, write a shell script (called mailmerge) that will take as its input the name of the letter template file and the name of the names file and produce a copy of the letter addressed to each recipient by his/her name. Use the Linux “sed” command in your script to produce each personalized letter from the letter template file.

Note:

The output of your script should be as many files as the number of recipients in the names file, i.e. one file for each recipient, where the filenames are appended by the names of the recipients to distinguish them from one another. For example: letter-to-Ali, letter-to-Amal …etc.

b. Pretty-Printing a Data File:

Some database and spreadsheet packages can save-files with comma-separated values, (CSVs) as one way to export their data, so other applications can import them for further processing. Given a data file with comma-separated fields, of the form:

Write a shell script to reformat the data and print it out to “stdout” in labeled, evenly-spaced columns as the following example, note the lengths of the label strings in the first line and the maximum string length in each column:

Full Name Street Address City State z ip, Phone Number Column labels Jones, Bill, 235 S. Williams St., Denver, CO, 80221, (303) 244-7989 Data line Data line Smith, Tom, 404 Polk Ave., Los Angeles, CA, 90003, (213) 879-5612

Explanation / Answer

# Hello World Program in Bash Shell

FILE="Newfile.txt"
while read line;
do
echo "$line"
cp Newfile1.txt letter-to-$line.txt
sed -i "s/USERNAME/${line}/g" letter-to-$line.txt
done < $FILE

Output

-------------

1. Here Newfile1.txt is notepad file in which i have taken below message

Hi USERNAME,

How are yout !

Thanks,

Admin

2. Newfile.txt has all the person name with line seperator

3. using the cp command we copied the letter contents to file like letter-to-<username>.txt

4. using sed command we replace all the string "USERNAME" with person name and close the file .

5. we performed step 3 and 4 in loop or for number of persons avaibale in Newfile.txt.

Thanks,

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