complex.gro
Great Red Owns Many ACres of Sand
6340
6SER N 1 2.724 13.826 0.957
6SER H1 2 2.685 13.863 1.041
6SER H2 3 2.783 13.748 0.979
.
.
.
405TYR C 6338 4.079 11.113 0.908
405TYR OC1 6339 4.166 11.065 0.896
405TYR OC2 6340 4.045 11.204 0.829
8.10576 5.73277 5.32581
lig.gro
MOL_GMX.gro created by acpype (Rev: 10101) on Tue Nov 14 21:43:44 2017
37
1 MOL C1 1 5.094 10.087 2.868
1 MOL C2 2 4.998 10.172 2.807
1 MOL C3 3 4.940 10.136 2.690
.
.
.
1 MOL H15 35 5.432 10.090 3.227
1 MOL H16 36 5.389 10.124 2.993
1 MOL H17 37 5.482 9.982 2.948
15.26200 11.53200 18.72600
I want insert the red part of lig.gro in the complex.gro before the last line
and
change the 2nd line number in complex.gro(6340+37)
the result is like next
complex.gro
Great Red Owns Many ACres of Sand
6377
6SER N 1 2.724 13.826 0.957
6SER H1 2 2.685 13.863 1.041
6SER H2 3 2.783 13.748 0.979
.
.
.
405TYR C 6338 4.079 11.113 0.908
405TYR OC1 6339 4.166 11.065 0.896
405TYR OC2 6340 4.045 11.204 0.829
1 MOL C1 1 5.094 10.087 2.868
1 MOL C2 2 4.998 10.172 2.807
1 MOL C3 3 4.940 10.136 2.690
.
.
.
1 MOL H15 35 5.432 10.090 3.227
1 MOL H16 36 5.389 10.124 2.993
1 MOL H17 37 5.482 9.982 2.948
8.10576 5.73277 5.32581
How can I reach the result by using shell script