I have 2 html files.
- index.html in a folder called "main"
- other.html in a folder called "other"
index.html has the below code:
<h1>My first story</h1>
<p>The pen was blue.</p>
other.html had the below code:
<p>The pen was black.</p>
I want to replace the paragraph content in "index.html" with the entire content of other.html so that index.html will give out the below result:
<h1>My first story</h1>
<p>The pen was red.</p>
I tried using the terminal command cd main && sed -e "s_<p>The pen was blue.</p>_$(cd ../other && sed 's:/:\\/:g' other.html)_" index.html
but I got the error message "bash: cd: main: No such file or directory". Even when I tried putting them in the same directory for the purpose of testing it did not work. But I need them in separate folders.
Update: I fixed the issue of accessing files in different directories by using the command sed -e "s_<p>The pen was blue.</p>_$(sed 's:/:\\/:g' other/other.html)_" main/index.html
but now I get the error message "sed: -e expression #1, char 54: unterminated `s' command"
How do I make it copy the contents of the 2nd file into the 1st file?