OSX
I have been grinding my teeth on a portion of code. I am building a bash script that edits a html email template. In the template, I have place holders for SED (or whatever program is appropriate) to use as anchors for find and replace, with user defined corresponding html code. The HTML code is pulled from a text file which contains all the different options of code. A simulation is:
(simplified)
If it was a single line, this works fine. But, the html snippet is usually multiple lines, filled with special characters such as:
Is there a better way to approach this? Thanks!
I have been grinding my teeth on a portion of code. I am building a bash script that edits a html email template. In the template, I have place holders for SED (or whatever program is appropriate) to use as anchors for find and replace, with user defined corresponding html code. The HTML code is pulled from a text file which contains all the different options of code. A simulation is:
(simplified)
Code:
The template with placeholders:
headerPlaceholder
productPlaceholder
infoPlaceholder
datePlaceholder
Code:
product=$(awk '/PRODSTART/,/PRODEND/{if (!/PRODSTART/&&!/PRODEND/) print}' snippets.txt) # range of desired html code selected from file, setup as a variable
sed -i '' "s/productPlaceholder/$product\n/g" ~/Desktop/emailTemplate.eml #replaces the placeholder with specified html code
Code:
<p><font color=3D"#929292">Product =
Code: </font><span class=3D"Apple-tab-span" style=3D"color: rgb(51, =
51, 51); white-space: pre; "> </span><font =
color=3D"#333333">prodnum</font><br><font color=3D"#929292">Model =