I'd always appreciate all helps from this website. I would like to relocate strings based on the index number from an index file.
Index numbers are shown on the first column in the index file (index.txt) and I would like to relocate "path" based on index numbers. Paths are placed in the same row if the index number is the same. For example, there are two zeros so path_sparc_ifu_dec_in_3826 is placed on the first row and path_sparc_ifu_dec_in_4349 is placed on the first row and next to path_sparc_ifu_dec_in_3826.
index.txt:
0 path_sparc_ifu_dec_in_3826 str DR - -
0 path_sparc_ifu_dec_in_4349 stf DR - -
1 path_sparc_ifu_dec_in_2374 stf DR - -
1 path_sparc_ifu_dec_in_4011 stf DR - -
2 path_sparc_ifu_dec_in_3078 stf DR - -
However, strings are written in another file (source.txt) and each "path" has four lines of strings.
source.txt:
path_sparc_ifu_dec_in_3826
dtu_inst_d[14]
dec_fcl_rdsr_sel_pc_d
0.8664
path_sparc_ifu_dec_in_4349
dtu_inst_d[18]
dec_swl_rdsr_sel_thr_d
0.795429
path_sparc_ifu_dec_in_2374
dtu_inst_d[13]
dec_dcl_cctype_d[2]
0.938914
path_sparc_ifu_dec_in_4011
dtu_inst_d[13]
ifu_exu_useimm_d
0.843643
path_sparc_ifu_dec_in_3078
dtu_inst_d[12]
ifu_exu_shiftop_d[2]
0.915818
The desired output is:
path_sparc_ifu_dec_in_3826 path_sparc_ifu_dec_in_4349
dtu_inst_d[14] dtu_inst_d[18]
dec_fcl_rdsr_sel_pc_d dec_swl_rdsr_sel_thr_d
0.8664 0.795429
path_sparc_ifu_dec_in_2374 path_sparc_ifu_dec_in_4011
dtu_inst_d[13] dtu_inst_d[13]
dec_dcl_cctype_d[2] ifu_exu_useimm_d
0.938914 0.843643
path_sparc_ifu_dec_in_3078
dtu_inst_d[12]
ifu_exu_shiftop_d[2]
0.915818
My idea is that (1)combining two files first and (2) relocate path info using the index number, but I don't know how to do this work. Probably, sed/awk is an appropriate language.
Any help is appreciated.
Best,
Jaeyoung