A
A
Alexander Valle2016-11-09 12:09:33
linux
Alexander Valle, 2016-11-09 12:09:33

Pasting text into index.html from bash?

The essence of the problem is what. There is a code, conditionally Yandex metric. The code uses a lot of special characters (pipes, quotes, etc.), you need to insert this code from the shell into index. The index has a label where to insert it (a certain keyword that can be replaced with a code. The code is conditionally in the file. I tried SED, but due to the presence of an abundant number of special characters, this is very problematic.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Taratin, 2016-11-09
@v1pby

Well, if there is only one place to insert, then it's easier to split index.html into 2 files, before the keyword and after.
Then output these files to the resulting file mixed with the desired code
cat before.index.html > index.html
mysupercommand >> index.html
cat after.index.html >> index.html
stackoverflow.com/a/6215113/2504704
blog .lavoie.sl/2012/11/simple-templating-system-us...

R
romy4, 2016-11-09
@romy4

replacement in awk. read the embed code into the variable and replace gsub(). this should not cause problems, unlike gray hair.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question