18 Aug 2004

Substitute “Mac” newlines with unix ones

Posted by Jacob Emcken

At work we have been struggling with bad newlines in php-pages created with dreamweaver on a Mac. The newlines screwed up grep results and was mainly just one big pain in the ***. This is a little note to my self about how to solve it.

This solution (parsed around by one of the guys at work, thanks Frank) should be carved in stone to be remember for eternity. The second best would be writing it on the Internet and I don’t have any stones not already written on at the moment:

tr '\r\n' '\n'  OUTPUTFILE

2 Comments to Substitute “Mac” newlines with unix ones

Frank Bille Jensen
August 23, 2004

Just remember that INPUTFILE and OUTPUTFILE must NOT be the same. Be it shouldn’t be too difficult to hack a little shell script if you want that functionality :-)

Frank Bille Jensen
August 24, 2004

Ohh and by the way: It converts both mac and dos line endings into unix line endings. :-D

Leave a comment