This does the trick:
perl -e"BEGIN{ binmode STDOUT }" -pe1 file.in > file.out [download]
In reply to Re: Removing ^M char AKA dos2unix by BrowserUk in thread Removing ^M char AKA dos2unix by afshinbozorg