1
1
What is the most efficient way to replace file's content between specific line numbers with another file?
Here is a sample:
main.txt
:
a b c
d e f
g h i
j k l
new.part.txt
x y z
p q r
s t u
The block of text starting at line 2 and ending at line 3 of main.txt
is replaced with new.part.txt
. The desired file is as follow:
a b c
x y z
p q r
s t u
j k l
This answer is for the case when range of the desired block is defined via marker strings. I need a solution that uses line numbers for defining range of the desired block.
...and today I learn that ed & sed have the
r
command. Ouch. – user1686 – 2014-02-08T10:10:33.740