This program will fix line endings in any text file as appropriate for the platform on which it is compiled. To use the program download the source and compile it on your system.
For GNU and Unix systems there is a man page (fixeol.1) donated by Steve Chervitz.
The point of this program is to be very portable.
It is easy to use on any system with a Standard C compiler.
There are no other dependencies.
You type "
fixeol filename" at the command line,
and the file will be fixed in place
so that all the line endings are appropriate.
It also makes sure that the last line ends properly.
This last bit ensures that you can then concatenate text files
without having the last line of one prepended
to the first line of the next.
fixeol has been used since 1991 without problems
on various Macintosh, Microsoft, Unix, and GNU operating systems.
Some systems may warn you on compilation to eschew the Standard C library function tmpnam() in favor of mkstemp(). On such systems you can define the macro USE_MKSTEMP before compiling to avoid that warning.
fixeol creates and writes to a temporary file.
When the conversion is complete the temporary file is renamed
to replace the original file.
On some systems the temporary file may be on a different volume,
and in this cases the rename will not work.
An error message is given to you,
and fixeol may try to move the file.
If you see the error message but no move command
you can still get fixeol to try to move the temporary file.
Recompile fixeol with the macro MOVE_COMMAND defined.
cc -DMOVE_COMMAND="mv %s %s" fixeol.c -o fixeol.
The first %s will be replaced with the temporary file name.
The second one will be replaced with the original file name.
Use SHIFT-Click here to download fixeolw.exe for Windows.
Cygwin: Note that Cygwin can be configured two different ways. The local files can be mounted in text mode for DOS line endings (CRLF) or in bin mode for Unix line endings (LF). Fixeol should work fine in either case. However, if you want to force CRLF line endings regardless of how Cygwin is configured you can use fixeolw.exe above. If you are compiling on a Cygwin system you can make either fixeol.exe or fixeolw.exe.
Some systems have a dos2unix command that does much the same thing as fixeol. It has more options and works only on Unix type systems. It also has a danger of losing files if you make the mistake of using file globbing. See the dos2unix man page for more details.
Another filter that can help after fixeol is trim.c.
Thanks to R. Steven Elliot for the original idea and first version. Thanks to Steve Chervitz for the man page and Mac OS X tips.
Eric Blossom - March 2004 - http://www.BlossomAssociates.net/FixEOL/