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.
gzipped tar, 0.3kB. SHA1 = c7e53800008a1e677503faa14b66f47d8f1f5525
For example, the command
% dos2mac foo
creates foo.mac with CRLF replaced by CR, etc.
This works also with wildcard characters, e.g. % mac2unix foo*.txt.
The scripts are mainly based on the command tr (translate characters).