I’m searching for a solution of this problem:
I have a file (tab-separated) like I show in the following blockquote. As you can see
there are lines that match the first part (Bold fields).
chr4 164440449 165354407 G1 P8002-51-75
chr1 220871675 220962596 G2 P2368-132-84
chr1 220871675 220962596 G2 P2369-152-116
chr1 220871675 220962596 G2 P2371-180-82
chr1 220871675 220962596 G2 P2372-223-129
chr1 220871675 220962596 G2 P2373-153-96
chr1 220871675 220962596 G2 P2370-104-78
chr5 126198405 126416440 G3 P9333-135-146
chr5 126198405 126416440 G3 P9334-151-116
Using AWK or PERL how could I manage to obtain the following output conserving the tab-separated format??? The general concept is to try to unify lines according to it’s first part, and append the last field
chr4 164440449 165354407 G1 P8002-51-75
chr1 220871675 220962596 G2 P2368-132-84 P2369-152-116 P2371-180-82 P2372-223-129 P2373-153-96 P2370-104-78
chr5 126198405 126416440 G3 P9333-135-146 P9334-151-116
The general concept is to try to unify lines according to it’s first part, and append the last field
One way using
perl:Assuming
infilewith the data of your question, output will be: