If you use more than one of Unix
and a Macintosh
, you may have come across the "newline characters"
problem: they all use different code
s for the end of a line. These codes are combinations of the ^M and ^J characters
(that is, Ctrl-M and Ctrl-J).
These characters are also known as "carriage return" and "line feed" or by their octal ASCII codes:
\015 Ctrl-M Carriage return
\012 Ctrl-J Line feed
When you have a file which uses the wrong newline convention, what can you do? Transferring it using ftp in
ASCII mode should sort it out. Or if you use Emacs 20, you can edit a file which uses any of these conventions,
and you can tell which one it uses from the symbol near the bottom right-hand corner:
Finally, here's how to use the Unix tr command to convert Windows or Mac text files to Unix text files:
Windows -> Unix tr -d '\015' < windowsfile > unixfile
Mac -> Unix tr '\015' '\012' < macfile > unixfile