merging multiple rows based on unique value using scripting or sql

I have a file like the one below.

cstmrid|PPM|Pre|FBB|Bundle|PPM_R|Pre_R|Bundle_R|FBB_R

11111 |Y |N |N |N |aaaaa| | |
11111 |N |Y |N |N | |pre | |

11111 |N |N |Y |N | | | |FBBr

Now I want a file which combines all the three rows and it should be like the one below.Except the cstmr_id all other fields should be appended as it is

cstmrid|PPM1|Pre1|FBB1|Bundle1|PPM_R1|Pre_R1|Bundle_R1|FBB_R1|PPM2|Pre2|FBB2|Bundle2|PPM_R2|Pre_R2|Bundle_R2|FBB_R2|PPM3|Pre3|FBB3|Bundle3|PPM_R3|Pre_R3|Bundle_R3|FBB_R3

11111 |Y |N |N |N |aaaaa| | | N |Y |N |N | |pre | | N |N |Y |N | | | |FBBr

Can someone help me in acheiving this using shell scriptiong or sql?

Thanks in advance.

Nikhila


Source: unix

Leave a Reply