Annoying as it may be, Windows and some FTP clients insert “carriage return” characters into text files. This is commonly referred to as “DOS” mode – you’ll know you’re editing a DOS mode file if your editor tells you so, or (like I found this morning) git tells you. I downloaded a bunch of files I had passed to a client, and git told me they had all been changed – they simply had carriage return (\r or ^M) characters inserted. Meh.
You can convert files with the
fromdos
command, which is located in the
tofrodos
package. Doing this recursively is pretty easy as well:
ewiltshi@davinci$ find . -type f | xargs fromdos
The above pattern is very useful –
find . -type f
just finds all files from the current directory and all subdirectories. The output of this then gets piped to
xargs fromdos
which runs the
fromdos
command on the found files. If you only wanted to run it on .css files, you could just change it up like so:
ewiltshi@davinci$ find . -type f -name "*.php" | xargs fromdos