Text Processing Awk – Printing Column Value Without New Line and Adding Comma

awktext processing

input.txt

 EN1
 EN2
 EN3
 EN4
 EN5

output

EN1,EN2,EN3,EN4,EN5

I have tried awk.But it is not printing with comma

awk 'BEGIN { OFS = ","} { printf $1}' input.txt

I have GNU Awk 4.0.0 version

Best Answer

awk 'BEGIN{ORS=","}1' input.txt

yields this:

EN1,EN2,EN3,EN4,EN5,

so is printing with a comma (so I'm not sure I understand your comment in your post about this not happening) though I suspect the trailing comma is a problem.

Tested with GNU Awk 3.1.7

Related Question