Convert Mac Line Endings

by damonp on January 5, 2006

in Apple / Mac,Linux,Microsoft / Windows

I wasted an hour last week messing with a CSV file I was massaging data in for import into a large SQL database only to find out the reason the import kept dying was because of the Mac line endings. There are many shell script, Perl scripts and shell one liners to convert line endings but I found a program called flip available for OSX, WinXP and Linux that can convert between all three.

Usage: flip [-t|-u|-d|-m] filename[s]
Converts ASCII files between Unix, MS-DOS/Windows, or Macintosh newline formats

Options:
-u = convert file(s) to Unix newline format (newline)
-d = convert file(s) to MS-DOS/Windows newline format (linefeed + newline)
-m = convert file(s) to Macintosh newline format (linefeed)
-t = display current file type, no file modifications

They are linked here locally as well:

Damon Parker is a freelance sysadmin and web developer in Texas. He specializes in server setup, server security and high performance server configurations. Need help setting up a web server or getting a server back online after a crash or hack? Email Damon

Raven Tools SEO Tools

{ 1 comment… read it below or add one }

Chris December 13, 2007 at 6:59 pm

Use it like this if you will (Assuming you want to convert all cpp and h line endings to dos):

cd to project directory
find . -name ‘*.cpp’ | xargs /tools/flip -d; find . -name ‘*.h’ | xargs /tools/flip -d;

Reply

Leave a Comment

Previous post:

Next post: