What I want to do is simply concatenate 2 files like the following example:
file 1 file 2
C1 O1
C3 O3
.. O5
O7
O9
O11
O13
O15
O17
O19
..
The desired out file is:
file 3
C1
O1
O9
O17
C3
O3
O11
O19
..
..
So, the patterns is: first C1 with O1, then 3 rows out in the file 2 (so, print O9); then another 3 rows out in file 2 (so, print O17). Then print C3 and O3, 3 rows out in file 2 (O10), 3 rows out (O18); then C5 ...etc.
I tried to do something with cat | paste - - - ...
but It didn't work :(
Any suggests?
Many thanks in advance
EDIT
I forgot to tell you they are big files. :)
Here is my input files
cat file 1
C 18 -2.182951850 -0.000000000 -6.517815410
C 20 -4.127401075 0.000000000 -0.446529291
C 22 -3.314258919 -2.494999886 -15.624910016
C 24 -6.071850300 0.000000000 5.624757806
C 26 -2.023950100 0.000000000 5.624757806
C 28 -4.286402584 -0.000000000 -12.589102506
C 30 -6.230851809 -0.000000000 -6.517815410
C 32 -0.079500634 0.000000000 -0.446529291
cat file 2
O 34 -1.393125174 -0.640765928 -5.738276269
O 36 -3.337574640 -0.640765928 0.333010828
O 38 -2.524270589 1.854234106 -14.845370570
O 40 -5.282024106 -0.640765928 6.404297925
O 42 -2.182951850 1.281531856 -6.517815410
O 44 -4.127401075 1.281531856 -0.446529291
O 46 -3.314258919 -1.213468178 -15.624910016
O 48 -6.071850300 1.281531856 5.624757806
O 50 -2.972778044 -0.640765928 -7.297355528
O 52 -4.917227269 -0.640765928 -1.226068432
O 54 -4.104085113 1.854234106 -16.404449463
O 56 -6.861676614 -0.640765928 4.845217687
O 58 -2.813776294 0.640765779 4.845217687
O 60 -5.076228778 0.640765779 -13.368642136
O 62 -7.020678123 0.640765779 -7.297355528
O 64 -0.869326828 0.640765779 -1.226068432
O 66 -2.023950100 -1.281531708 5.624757806
O 68 -4.286402584 -1.281531708 -12.589102506
O 70 -6.230851809 -1.281531708 -6.517815410
O 72 -0.079500634 -1.281531708 -0.446529291
O 74 -1.234123906 0.640765779 6.404297925
O 76 -3.496576390 0.640765779 -11.809563365
O 78 -5.441025615 0.640765779 -5.738276269
O 80 0.710325077 0.640765779 0.333010828
C18 must be followed by O34, O42 and O50. Then C20 followed by O36, O44 and O52 and so on:
cat file 3
C 18 -2.182951850 -0.000000000 -6.517815410
O 34 -1.393125174 -0.640765928 -5.738276269
O 42 -2.182951850 1.281531856 -6.517815410
O 50 -2.972778044 -0.640765928 -7.297355528
C 20 -4.127401075 0.000000000 -0.446529291
O 36 -3.337574640 -0.640765928 0.333010828
O 44 -4.127401075 1.281531856 -0.446529291
O 52 -4.917227269 -0.640765928 -1.226068432
.. .. ............ ............. .........
The output generated by Tom code is this:
Tom output
C 18 -2.182951850 -0.000000000 -6.517815410
O 34 -1.393125174 -0.640765928 -5.738276269
O 42 -2.182951850 1.281531856 -6.517815410
O 50 -2.972778044 -0.640765928 -7.297355528
O 58 -2.813776294 0.640765779 4.845217687
O 66 -2.023950100 -1.281531708 5.624757806
O 74 -1.234123906 0.640765779 6.404297925
C 20 -4.127401075 0.000000000 -0.446529291
O 36 -3.337574640 -0.640765928 0.333010828
O 44 -4.127401075 1.281531856 -0.446529291
O 52 -4.917227269 -0.640765928 -1.226068432
O 60 -5.076228778 0.640765779 -13.368642136
O 68 -4.286402584 -1.281531708 -12.589102506
O 76 -3.496576390 0.640765779 -11.809563365
C 22 -3.314258919 -2.494999886 -15.624910016
O 38 -2.524270589 1.854234106 -14.845370570
O 46 -3.314258919 -1.213468178 -15.624910016
O 54 -4.104085113 1.854234106 -16.404449463
O 62 -7.020678123 0.640765779 -7.297355528
O 70 -6.230851809 -1.281531708 -6.517815410
O 78 -5.441025615 0.640765779 -5.738276269
and so on
Any suggest?
Thank you