replace new lines with comas in shell
Posted
by
mpapis
on Stack Overflow
See other posts from Stack Overflow
or by mpapis
Published on 2013-08-04T08:47:17Z
Indexed on
2013/10/26
3:54 UTC
Read the original article
Hit count: 145
I want to replace new lines in text with coma or space but do not change the last new line.
I know of this question: How to replace new lines with tab characters - but it does produce an tab on end instead of new line.
So far I have come with:
awk 'NR>1{printf","} {printf $1} END{printf"\n"}'
Is there an easier way to do this? This is not an assignment, I am just curious want to level up my scripting.
© Stack Overflow or respective owner