I moved a folder of HTML files from a Mac to a Unix box and now the files look messy. I see lots of ^M characters in vi. How can I clean it up?
Applications on the Mac platform usually use carriage returns (#13 or ^M) as line separators.
Windows applications use carriage return + line feed (#13#10 or ^M^J).
Unix applications use only line feed (#10, ^J)
The best thing to do is to configure your ftp tool (e.g. Dreamweaver) to send files 'ASCII' style.
You can also use the following unix command to edit your file. The '\r' is the carriage return, replaced by a newline '\n'
The second command does the same, using perl instead.
If your Linux installation has the tool mac2unix (e.g. in /usr/bin) then you may use this tool. It can take wildcards!
tr '\r' '\n' <index.html >index2.html
perl -p -e 's/\r/\n/g' <index.html >index2.html
find . | mac2unix