Text from Unix, Mac, and PC files

There are three main ways lines in a text file are separated from each other, using the ASCII characters \012 (^J) and/or \015 (^M): For example, Mathematica notebooks sometimes carry this message:
Data for notebooks contains only printable 7-bit ASCII and can
be sent directly in email or through ftp in text mode.  Newlines
can be CR, LF or CRLF (Unix, Macintosh or MS-DOS style).

In using FTP or Fetch, selecting ``ascii'' mode, the appropriate changes in line separation are made when transferring a text file from one kind of computer to another. However, Netscape is known to err in making text transfers, perhaps because it uses ``binary'' rather than ``ascii'' mode with FTP. How can one compensate for this? If nothing else, one may provide up to three different versions of the same text file; a version for use by Macs, one by PCs, and one by Unix computers. On a Unix system one can use tr to convert between the Mac and Unix line endings:


     tr '\015' '\012'  Mac.txt  >  Unx.txt
     tr '\012' '\015'  Unx.txt  >  Mac.txt

On a Unix system, the same 3-line text file
line 1
line 2
line 3
in all three forms have the following word counts:

     unix>  wc *.txt
     
            0       4      21 mac.txt
            3       6      24 pc.txt
            3       6      21 unix.txt