About this site
Links to us
General :: Linux :: shell
Linux shell programming/ scripting, shortcuts and general know-how.
This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.
Generated 8:00:36 on Jul 12, 2020
Converting Mac style text files to Unix style
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
|Most recent comments