Replace comma with newline in sed on MacOS?

WildBill picture WildBill · May 25, 2012 · Viewed 317.3k times · Source

I have a file of id's that are comma separated. I'm trying to replace the commas with a new line. I've tried:

sed 's/,/\n/g' file

but it is not working. What am I missing?

Answer

Prince John Wesley picture Prince John Wesley · May 25, 2012

Use tr instead:

tr , '\n' < file