Skip to main content
4 of 5
Command corrected
Prabhjot Singh
  • 2.4k
  • 1
  • 6
  • 20

Using awk:

$ awk '{if (NR>1) print a "," OFS; a=$0}END {if (NR) print ""}'

If only comma is needed without space and all records have only one fields, then datamash may be used.

$ datamash -W collapse 1 <file
Prabhjot Singh
  • 2.4k
  • 1
  • 6
  • 20