Druid628 :: Tech Tips :: DOS Line terminators in Unix (^M)

^M

Ok if you've ever FTP'd an ASCII over from a Windows based machine to a UNIX machine you have probably seen this lovely little guy at the end of your lines:

^M

Here is the way to get rid of him. Whenever I run across this problem I can't ever seem to remember how to properly get rid of it well I decided I'd put up a tutorial for me and anyone else who wants to know how to correct this (it can't hurt to have another copy of it out here on the internet can it?).

If you're using vi then simply use this command

:%s/^M//g

but remember the ^M isn't just the ^ and shift-m. This ^M is brought to you by
Ctrl-V then Ctrl-M.

For those of you who travel through the Perly gates you can use this:

perl -pi -e 's/\015//g' files

Just thought everyone would benefit from this.