I have a list. There are some lines whose Column 1 is the same.
ENSG00000005187 chr16 19 209 0.079
ENSG00000005187 chr16 20 206 0.172
I want to cluster those lines sharing the same Column 1 into one line like below:
ENSG00000005187 chr16 19 209 0.079 chr16 20 206 0.172
How can I do it using bash?
thx
You can do this using
awk:That snippet assumes all your lines have exactly five fields.
By the way the
joinstandard utility comes close to doing what you need, but unfortunately is designed to join two different files; joining a file with itself produces spurious lines. Nevertheless you should probably check it out because if you do this kind of task often you’re bound to find it useful at some time.