I have to insert a textblock into multiple (> 200) html files. I decided to address the assignment using bash.
The textblock that has to be inserted is a multiliner:
textblockvar='
<body class="article toc2 toc-right">
<div id="readspeaker-button1" class="rs_skip rsbtn rs_preserve">
<a rel="nofollow" class="rsbtn_play" accesskey="L" title="Read
out with ReadSpeaker" href="//app-eu.readspeaker.com/cgi-bin
/rsent?customerid=5&lang=nl_nl&voice=Ilse&re$
<span class="rsbtn_left rsimg rspart"><span
class="rsbtn_text"><span>Lees voor</span></span></span>
<span class="rsbtn_right rsimg rsplay rspart"></span>
</a>
</div>
'
The textblockvar
will replace the <body class="article toc2 toc-right">
tag, that seems to be consistent in all 200+ html files.
I tried various techniques to execute the substitution:
FILES=leerstof/*/*.html
for f in $FILES
do
sed -e "s|'<body class="article toc2 toc-right"'|${textblockvar}|g" $f
done
However, the script always ends up with a fatal error: "unterminated `s' command".
I tried to exchange quotes, tried without quotes, but still the error persists.
Maybe my solution is not the best option. Are there any workarounds available?