Join output fields with commas.
Section: awk Fields and Records
Set output field separator
bash
bash
awk 'BEGIN{OFS=","} {print $1, $2, $3}' file.txtExplanation
`OFS` controls how fields are separated when printed with commas in `print`.
Learn the surrounding workflow
Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.
Related commands
Same sheet · prioritizing awk Fields and Records
Print selected columns
Show the first and third whitespace-delimited fields.
Print rows matching a condition
Show lines where column 3 is greater than 100.
Use BEGIN and END blocks
Print headers and footers around processed output.