Windows vs Linux end-of-line (EOL) conventions


Bill Press
11-06-2007, 09:06 PM
A user points out that the NR3 code files on the CD or purchased code download use the Windows end-of-line convention (\012\015 = ^M^J = \r\n) and not the Linux/Unix/Mac OS X convention (\012 = ^J = \n), and wonders if this will cause problems on a Linux or OS X machine.

Almost all Linux compilers and editors these days can handle Windows text files without a problem, so generally you don't have to do anything. However, if you want to change the files, most Linux machines have a command "dos2unix" that can do this. Try typing "man dos2unix" in a command window for help.

If you don't have dos2unix, then the following line of awk in a command window should work:
awk '{ sub("\r$", ""); print }' winfile.txt > unixfile.txt

Mac OS X machines usually don't have the dos2unix command, but they do have awk, so the above should work on them.