This is a simple and contrived example of a block replacement. Adapt it to your own application.
The first sed
makes a copy of lines 1-3 in a work file and the second sed
makes a copy of lines 7-EOF in another work file. The cat
combines those work files with a second input file making a conceptual "sandwich."
sed '3q' $InFile1 >$Work1
sed '1,6d' $InFile1 >$Work2
cat $Work1 $InFile2 $Work2 >$OutFile
Executing this code produced this OutFile ...
Daniel B. Martin