Eclipse and Windows newlines
As mentioned here and here:
Set file encoding to
UTF-8
and line-endings for new files to Unix, so that text files are saved in a format that is not specific to the Windows OS and most easily shared across heterogeneous developer desktops:
- Navigate to the Workspace preferences (General:Workspace)
- Change the Text File Encoding to
UTF-8
- Change the New Text File Line Delimiter to Other and choose Unix from the pick-list
- Note: to convert the line endings of an existing file, open the file in Eclipse and choose
File : Convert Line Delimiters to : Unix
Tip: You can easily convert existing file by selecting then in the Package Explorer, and then going to the menu entry File : Convert Line Delimiters to : Unix
I had the same, eclipse polluted files even with one line change. Solution: Eclipse git settings -> Add Entry: Key: core.autocrlf Values: true
There is a handy bash utility - dos2unix
- which is a DOS/MAC to UNIX text file format converter, that if not already installed on your distro, should be able to be easily installed via a package manager. dos2unix man page
In addition to the Eclipse solutions and the tool mentioned in another answer, consider flip. It can 'flip' either way between normal and Windows linebreaks, and does nice things like preserve the file's timestamp and other stats.
You can use it like this to solve your problem:
find . -type f -not -path './.git/*' -exec flip -u {} \;
(I put in a clause to ignore your .git directory, in case you use git, but since flip ignores binary files by default, you mightn't need this.)