I would like to delete duplicated chunks of strings in a file
One chunk is comprised of four lines such as:
path name
starting point
ending point
voltage number
I would like to delete duplicated chunks on the same row(?) if the ending point is duplicated.
For example, ending points of the first and the second chunk are same in the first row and I would like to only keep the first chunk. Therefore, the second chunk is removed on the first row.
In the second row, ending points of the first and the third chunk are same and keep the first chunk.
input.txt:
path_sparc_ffu_dp_out_1885 path_sparc_ffu_dp_out_2759 path_sparc_ffu_dp_out_3115
R_1545/Q R_1541/Q R_1545/Q
dp_ctl_synd_out_low[6] dp_ctl_synd_out_low[6] dp_ctl_synd_out_low[2]
0.926208 0.910592 0.905082
path_sparc_ffu_dp_out_699 path_sparc_ffu_dp_out_712 path_sparc_ffu_dp_out_819
R_1053/Q R_1053/Q R_1053/Q
dp_ctl_synd_out_low[2] dp_ctl_synd_out_low[6] dp_ctl_synd_out_low[2]
0.945436 0.945436 0.9435
output.txt:
path_sparc_ffu_dp_out_1885 path_sparc_ffu_dp_out_3115
R_1545/Q R_1545/Q
dp_ctl_synd_out_low[6] dp_ctl_synd_out_low[2]
0.926208 0.905082
path_sparc_ffu_dp_out_699 path_sparc_ffu_dp_out_712
R_1053/Q R_1053/Q
dp_ctl_synd_out_low[2] dp_ctl_synd_out_low[6]
0.945436 0.945436
I think awk/sed can do this work. Any help is appreciated.
Best,
Jaeyoung