shell replace cr\lf by comma

vinnitu picture vinnitu · Jan 4, 2011 · Viewed 81.9k times · Source

I have input.txt

1
2
3
4
5

I need to get such output.txt

1,2,3,4,5

How to do it?

Answer

eumiro picture eumiro · Jan 4, 2011

Try this:

tr '\n' ',' < input.txt > output.txt