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 the following task: Suppose that you want

ID: 3851903 • Letter: W

Question

Write a bash shell script to carry out the following task:

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.

d. 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: l. 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

Explanation / Answer

mail_template.txt

Dear NAME

Please read this letter carefully

Your Dark Knight

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

names.txt

Ali

Amal

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

merge.sh

#!/bin/sh
template=$(cat mail_template.txt)
for name in $(<names.txt)
do
   sed s/NAME/$name/ <$template >letter
   echo $letter > "letter-to-"$name
done

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