Insert the text in index.html from bash?

The essence of the problem in it.There is code conditional Yandex Metrika.The code uses a lot of special characters ( pipes, quotes, etc.), you need of applying this code to insert into index. In the index there is a mark where it is to insert (a key word which can be replaced with a code.Conventionally, the code resides in the file.Tried SED'ohms,but due to the presence of abundant numbers of special characters,it is very problematic.
July 2nd 19 at 18:11
2 answers
July 2nd 19 at 18:13
Solution
Well, if places to insert only one, it is easier to break index.html 2 file, to key words and after.
Then bring these files in the result mixed with desired code

cat before.index.html > index.html
mysupercommand >> index.html
cat after.index.html >> index.html

UPD
stackoverflow.com/a/6215113/2504704
blog.lavoie.sl/2012/11/simple-templating-system-us...
Thanks,probably still is the best solution.Decided so.

grep -A 99999 META index.html | grep -v META > index.after (META - keyword.Output all after the keyword except for the keywords.)
grep -B 99999 META index.html | grep -v META > index.before (to output all keywords except the keyword.)

Then all stuffed back in the index in the correct order.

cat index.before > index.html
cat metrica >> index.html (push code from a file)
cat index.after >> index.html (shoving all that was after the label)

???
PROFIT!

Thanks for the tip. - bella_Gorczany commented on July 2nd 19 at 18:16
July 2nd 19 at 18:15
replacement in awk. read into the variable code of the insertion and replaced with gsub(). this should not cause problems, unlike Seda.

Find more questions by tags sedAWKLinuxHTML