Removing ^M from your Mac text files
Here are some tips for removing those troublesome carriage return characters from Mac OS text files:
Using perl
perl -pi -e 's/\r/\n/g' <filename>
See Mac vs. UNIX line breaks for an explanation of the perl command.
In VIM:
Go to command mode and run the search and replace command.
.,$s/^M/^M/g
Note: To get ^M, type control+shift+v then control+shift+m.
For more information about text file line breaks, see:
Commands for Dealing with Text Files

