jeudi 29 janvier 2015

How to merge separated fields in rows into one based on common fields in AWK / UNIX


Vote count:

0




I am still just a new user to UNIX and especially to AWK. I am having the problem to merge rows based on first 2 columns values. My original data from a file as below:


ID1 ID2 Field1 Field2 1 1 11F1 11F2 1 2 12F1 12F2 2 1 21F1 21F2 2 2 22F1 22F2 ID1 ID2 Field3 Field4 1 1 11F3 11F4 1 2 12F3 12F4 2 1 21F3 21F4 2 2 22F3 22F4 ID1 ID2 Field5 Field6 1 1 11F5 11F6 1 2 12F5 12F6 2 1 21F5 21F6 2 2 22F5 22F6


As you noticed, columns are split into different rows/block but IDs fields and columns heading are still available and repeated. So what i want to achieve is as follow:


ID1 ID2 Field1 Field2 Field3 Field4 Field5 Field6 1 1 11F1 11F2 11F3 11F4 11F5 11F6 1 2 12F1 12F2 12F3 12F4 12F5 12F6 2 1 21F1 21F2 21F3 21F4 21F5 21F6 2 2 22F1 22F2 22F3 22F4 22F5 22F6


Merge all into as a single block/table. But don't know how to do it in AWK, or is it possible do achieve with AWK.


Thank a lot. Htat Ko



asked 3 mins ago







How to merge separated fields in rows into one based on common fields in AWK / UNIX

Aucun commentaire:

Enregistrer un commentaire