I am trying to write an awk string to print column data in rows based on match.
My file is as below:
$ cat 1.txt
2016-05-10,UJ,ALL 1 7
2016-05-10,UJ,ALL 1 10
2016-05-10,UJ,ALL 1 9
2016-05-10,UJ,ALL 1 8
2016-05-10,UJ,ALL 1 14
2016-05-10,UJ,ALL 1 8
2016-05-10,UJ,ALL 1 12
2016-05-10,UJ,ALL 2 11
2016-05-10,UJ,ALL 1 10
2016-05-10,UJ,ALL 2 12
2016-05-10,UJ,ALL 2 9
2016-05-10,UJ,ALL 1 13
expected output is as below (uniq key match is before first space i.e. 2016-05-10,UJ,ALL)
2016-05-10,UJ,ALL<\tab>1 1 1 1 1 1 1 2 1 2 2 1<\tab>7 10 9 8 14 8 12 11 10 12 9 13
I am using below awk pattern matching
awk '$1 != prev{printf "%s%s",ors,$1; ors=ORS; ofs="\t"} {printf "%s%s",ofs,$2; ofs=OFS; prev=$1} END{print ""}' 1.txt
but it is not working on last coulmn, i tried all possible combinations but no success... please suggest.
