0. Internet 1. Text 2. Graphics 3. System 4. File 5. Misc 6. Palm 7. OS X |
Convert between Mac, Unix, and DOS/Windows EOL characters (CR, LF, CRLF) # Craig Stuart Sapp's flip converts ASCII files between between Mac (OS 9 and ealier), *nix (including OS X), and DOS/Windows newline formats. As the provided OS X binary was compiled in 10.3 for PowerPC, I've compiled a much smaller Intel binary in 10.5. flip's source code also explains a method for converting line endings via Perl: Mac to Unix: perl -i -pe 's/\015/\012/g' mac-file Mac to DOS: perl -i -pe 's/\015/\015\012/g' mac-file Unix to Mac: perl -i -pe 's/\012/\015/g' unix-file Unix to DOS: perl -i -pe 's/\012/\015\012/g' unix-file DOS to Unix: perl -i -pe 's/\015\012/\012/g' dos-file DOS to Mac: perl -i -pe 's/\015\012/\012/g' dos-fileHere are a few more possibilities from Jacek Artymiak's Filtering files with tr:
Mac -> UNIX: tr '\r' '\n' < macfile > unixfile
UNIX -> Mac: tr '\n' '\r' < unixfile > macfile
DOS -> UNIX: tr -d '\r' < dosfile > unixfile
UNIX -> DOS: '{ print $0"\r" }' < unixfile > dosfile
/nix | Nov 08, 2009 |
Categories
Blosxom Archive
2010: 9 8 7 6 5 4 3 2 1
2009: 12 11 10 9 8 7 6 5 4 3 2 1 2008: 12 11 10 9 8 7 6 5 4 3 2 1 2007: 12 11 10 9 8 7 6 5 4 3 2 1 2006: 12 11 10 9 8 7 6 5 4 3 2 1 2005: 12 11 10 Blogger Archive
Ezine Archive
|