I have two textfiles: file1
and file2
, both with several lines.
$ cat file1
line one
line two
line three
line four
line five
$ cat file2
line A
line B
line C
line D
line E
line F
I would like to substitute a range of lines of file1
(from line 1_start
to line 1_end
) with a range of lines of file2
(from line 2_start
to line 2_end
).
For example, substitute lines 2,4
in file1
with lines 3,5
from file2
.
What I only could do till now is to extract the needed lines from file2
with
$ sed -n 3,5p file2
But it doesn't help putting them in file1
. Is it possible with sed
? If not, is it possible with a similar tool?