I am trying to replace a string with sed
(stream editor), however I am getting errors thrown back. Probably because I am not using the string correctly, because of the symbols.
I am trying to replace the following string:
<VirtualHost |IP|:|PORT_80| |MULTI_IP|>
with
<VirtualHost 127.0.0.1:8080 |IP|:8080 |MULTI_IP|>
In the file called virtual_host2.conf
Buw when I try several things, I always get errors back like:
sed: -e expression #1, char 90: unterminated `s' command
sed: -e expression #1, char 20: unknown option to `s'
I am not that experienced with sed
, but I can replace text strings normally. But I think because of the symbols in the current string, like |
, <
and >
it doesn't work like I would.
Can someone please give me a working example on how to replace the above? Or point me in the right direction.
I tried the following myself:
sed -i 's<VirtualHost |IP|:|PORT_80| |MULTI_IP|>/<VirtualHost 127.0.0.1:8080 |IP|:8080 |MULTI_IP|>' /virtual_host2.conf
sed -i 's|<VirtualHost |IP|:|PORT_80| |MULTI_IP|>|<VirtualHost 127.0.0.1:8080 |IP|:8080 |MULTI_IP|>|g' /virtual_host2.conf
But both give the error as mentioned above.
Any idea?