Quantcast
Channel: Question and Answer » gawk
Viewing all articles
Browse latest Browse all 13

Combine range of columns with the same key

$
0
0
Input file tab separated:
A   |B   |  C | KEY  |  D|  E|  F  |G     | H | I | J   |   k |      
----|----|----|------|---|---|-----|------|---|---|-----|-----|      
word|word|word| one  |  8|  8|qw123| ""   | ""| ""| word| word|      
word|word|word| one  |  8|  8|qw234| ""   | ""| ""| word| word|      
word|word|word| one  |  8|  8|qw111| er432| ""| ""| word| word|      
word|word|word| seven|  8|  8|tr123| ""   | ""| ""| word| word|      
word|word|word| seven|  8|  8|ww000| ""   | ""| ""| word| word|      


Desired Output:                                                                     
A   |B   |  C | KEY  |D |E |F    |G    |H    |I    |J   |K   |  
----|----|----|------|--|--|-----|-----|-----|-----|----|----|
word|word|word|one   | 8| 8|qw123|qw234|qw111|er432|word|word|
word|word|word|one   | 8| 8|qw123|qw234|qw111|er432|word|word|
word|word|word|one   | 8| 8|qw123|qw234|qw111|er432|word|word|
word|word|word|seven | 8| 8|tr123|ww000|""   |""   |word|word|
word|word|word|seven | 8| 8|tr123|ww000|""   |""   |word|word|

It is about merging the range of columns [F to I] with the same KEY.
Is it possible to achieve this without using arrays in AWK? How I can control when the value of the key column changes?


Viewing all articles
Browse latest Browse all 13

Trending Articles