When a file is saved in Windows and then moved to a Linux system the formatting differences can cause a variety of problems. To effectively use these files you will need to change the format from Windows/DOS to Unix. This conversion occurs by simply removing the Windows carriage return characters.
I have explained how to use the tr command remove these windows carriage returns, but when you have a large amount of files to convert this can become tedious. As a solution to this I have written a BASH script to convert all text files within a directory.
for file in /directory/to/convert/*
if [[ -f $file && `file $file | grep text` ]]
tr -d '\r' < $file > "$file"_clear
mv "$file"_clear $file