Issue
Let's say I have a file called File1.txt
that has the string
Hamburger
And I have another file called File2.txt
that has the string:
I love Pizza
I want to use the sed
command to make changes such that it copies all the text from File1.txt
i.e. Hamburger
and replace it in File2.txt
with the word Pizza
so that the final output in File2.txt
would be
I love Hamburger
Is there a way to do this suing the sed command ?
Here's an example of code I am trying to use but it doesn't work:
sed -e '/Hamburger/{r File1.txt' -e 'd}' File2.txt
Solution
You can try this sed
$ sed "s/Pizza/$(cat File1.txt)/" File2.txt
I love Hamburger
Answered By - HatLess Answer Checked By - Senaida (WPSolving Volunteer)