TR not removing carriage returns

I have a CSV with carriage returns in place of newlines. I am trying to use tr to remove them, but it isn't working.

Academic year,Term,Course name,Period,Last name,Nickname
2012-2013,First Semester,English 12,4th Period,Arnold,Adam
2012-2013,First Semester,English 12,4th Period,Adams,Jim
2012-2013,First Semester,English 12,4th Period,Smith,John

Here is what I am running it through:

tr '\r' '\n' <input.csv >output.csv

When I open the output in TextWrangler and grep for /r, it shows up at the end of every line, and \n is nowhere to be found. Any ideas what I am missing?

od -c input.csv will show you what the input file contains.

It's probably just in DOS format (with both \n and \r) and you just want to delete any \r characters, with:

tr -d '\r' < input.csv > output.csv
1 Like