[PLUG] Translating ^M to \n

Paul Heinlein heinlein at madboa.com
Mon Aug 12 22:24:01 UTC 2019


On Mon, 12 Aug 2019, Paul Heinlein wrote:

> On Mon, 12 Aug 2019, Rich Shepard wrote:
>
>>  On Mon, 12 Aug 2019, Paul Heinlein wrote:
>>
>>>   tr -d '\r' < infile.csv > outfile.csv
>>
>>  Thanks, Paul. I didn't know if tr would recognize ^M as \r so I used
>>  	cat <infile> | tr "^M" "\n" and that changed it to the Mac format,
>>  rather than the UNIX format, for some reason
>
> My original recipe above merely deletes carriage returns; it leaves newlines 
> intact.

Also, you can use "od -c" to verify the C-style character name tr will 
recognize.

od -c inffile | less

If you want, you can compare that output with that of "od -a" which 
will show "nl" for "\n" and cr for "\r".

-- 
Paul Heinlein
heinlein at madboa.com
45°38' N, 122°6' W


More information about the PLUG mailing list