Is there any bash solution to do a simple "search and replace" without escaping hassle? I try to replace `<!-- JavaScript -->` in an html file with the content of a complex javascript file.

I have tried

```
JS=$(<"path to javascript file")
sed "s|<!-- JavaScript -->|${JS}|g" "path to html file" > "path to html file"

```

but just get

```
sed: -e Ausdruck #1, Zeichen 16: Nicht beendeter `s'-Befehl

```

In Powershell I do

```
$CSS = Get-Content "path to javascript file"
(Get-Content "path to html file").replace('<!-- JavaScript -->', $JS) | Set-Content "path to html file" -Force

```

and it just works like a charm, without escaping hassle.

**Update (but doesn't work too):**

```
JS=$(<"${TemporaryPath}/${Project}/${Project}.js")
E='!'
sed "s|<${E}-- JavaScript -->|${JS}|g" "path to html file" > "path to html file"

```

I get `sed: -e Ausdruck #1, Zeichen 68: Nicht beendeter s'-Befehl`. If I change the content of $JS to something basic like "foo" it works. Probably a problem with the javascript content of $JS? What can I do that the content of $JS doesn't matter?