CR/LF conversion

Unix shell scripts for line-ending conversion

Historically, the Mac OS, DOS/windows and Unix use different character sequences to indicate the end of a line (EOL). While the Mac uses the ASCII character 13 (carriage return, CR), it is ASCII 10 (Linefeed, LF) in Unix and the combination of both in DOS/Windows (CR followed by LF, CRLF).

With the following shell scripts, text files can be translated from one convention to the other:

dos2mac, dos2unix, unix2mac, mac2unix.

The corresponding file extensions (.mac, .unix) are added to the file name of the converted file (the original file is left untouched).

Important disclaimer: these scripts are supplied without warranties of any kind, use them at your own risk! Don't use them on binary (non-text) files.

The scripts are mainly based on the command tr (translate characters).