I want to replace the lines matching a pattern from one file from the lines in order from another file, for example, given:
file1.txt:
aaaaaa
bbbbbb
!! 1234
!! 4567
ccccc
ddddd
!! 1111
we like to replace the lines starting with !! with the lines of this file:
file2.txt:
first line
second line
third line
so the result should be:
aaaaaa
bbbbbb
first line
second line
ccccc
ddddd
third line
Best Answer
Easy can be done with awk
Other version