Removing ^M characters

If you have been using Linux in a mixed environment for any amount of time you have probably come across the dreaded ^M. That nasty control character can mess up compiling and render scripts useless unless they are removed. Here is a quick command line sed maneuver you can use to get rid of them. Oh, and remember, to create the control character, don’t use the carrot symbox(^) + M, you have to use Ctrl+V then Ctrl+M to create it, or else it means something totally different.

sed -i 's/^M/\n/g' fileToReplaceControlChars.txt
  1. #1 by Rich Freedman on June 15, 2008 - 2:40 pm

(will not be published)