My problem is this: I had a text file formatted like this:
12 apple
78 orange
12 prune
12 prune
78 berries
78 cake
I need to reassign the values in the form:
12 apple, prune
78 orange, berries, cake
I did this with awk. {sbj=$2","; a[$1]=a[$1]sbj}END{for (i in a) print i, a[i]}
But the problem is that now I have a file formatted as:
12 apple one
78 orange one
12 prune two
12 prune two
78 berries two
78 cake two
And the output of desire:
12 apple one
78 orange one
12 prune two
78 berries, cake two
I tried to do this by mixing awk and bash, but that didn't help. The only option I can do now is to store each series ("one", "two") in separate files and process them separately using the above code, and then sum all the arrays into a file. But this is a difficult and awkward decision. Is it possible to do this in a single file? Thanks for any advice.
Mirrg