Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Try just converting newline with ,:
newline
,
<your command> | tr -s '\n' ','
If you want to use awk, just print with no newline:
awk
<your command> | awk ''NR > 1 {printf "%sprintf(",") } {printf "%s",$0}'
<your command> | awk '{printf "%s,",$0}'
<your command> | awk 'NR > 1 { printf(",") } {printf "%s",$0}'