Group second column based on first column awk
Can someone please help in parsing the following data. Below are the input, output and tried attempt details.
Input data:
foo 1
bar 12
foo 23
foo 45
bar 223
bar 123
bar 3478
foo 45
zoo 1
zoo 0987
foo 5
Output data:
foo 1 23 45 45 5
bar 12 223 123 3478
zoo 1 0987
Attempt(Failed):
awk '{a[$1]=$2;next}END{for(i in a) print i,a[i]}' input
zoo 0987
foo 5
bar 3478