Combining records with same key
Hello.
I'm new to Linux and struggling to learn sed on my own. Therefore a sed solution is most desirable, but all advice will be gratefully accepted. Input file (already sorted on the key field): 204 Daniel Barton 206 Mary Halston 206 David Coleman 206 Carson Coleman 207 Roland Highsmith 207 Annie Highsmith 209 Connie Ward Desired output file: 204 Daniel Barton 206 Mary Halston David Coleman Carson Coleman 207 Roland Highsmith Annie Highsmith 209 Connie Ward How may this be achieved? Thanks in advance. Daniel B. Martin |
Not sure in sed (and not sure the right tool), but this works:
Code:
awk '{ arr[$1] = arr[$1]" "$2" "$3 }END{ for (x in arr) print x arr[x]}' file |
All times are GMT -5. The time now is 05:28 PM. |