Alex Rivera | Logout

Shell replace CR\LF by comma

Asked 2011-01-04T13:50:07.277
86

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?

Edit
Report

1 Answer

24

In response to @Jonathan's comment to @eumiro's answer:

tr -s '\r\n' ',' < input.txt | sed -e 's/,$/\n/' > output.txt
answered 2011-01-04T15:42:04.067

Your Answer