Não sei se você está interessado em Python, e provavelmente há uma maneira incisiva de usar uma linguagem diferente, mas o Python pode fazer isso com algo como:
Código:
# describe where the text block is located
f1_start = 2, 18
f1_size = 4, 40
f2_start = 4, 19
# open all three files
with open('file1', 'rU') as f1, open('file2', 'rU') as f2, open('file3', 'w') as f3:
# skip some lines in file1
for _ in range(f1_start[0] - 1):
f1.readline()
# write first block of file2 to file3
for _ in range(f2_start[0] - 1):
f3.write(f2.readline())
# read from and merge lines in file1 and file 2
for _ in range(f1_size[0]):
l1 = f1.readline()[f1_start[1]:f1_start[1] + f1_size[1]].rstrip()
l2 = f2.readline()
l3 = l2[:f2_start[1]] + l1 + l2[f2_start[1]:]
f3.write(l3)
# write remaining lines from file2 to file3
while True:
l2 = f2.read()
if not l2:
break
f3.write(l2)
Resultado:
...
0 1 0 1 0 1
H 0 -9.92247800 1.33807800 -0.69208300 H
S 0 -9.74392800 0.01073000 -0.55448800 H
C 0 -7.98603700 0.04294200 -0.19355700 H
C 0 -7.45325900 -1.23715800 0.02112600 H
...