DelphiFAQ Home Search:

Converting Mac style text files to Unix style


comments192 comments. Current rating: 3 stars (185 votes). Leave comments and/ or rate it.


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

// convert all html files using /usr/bin/mac2unix
mac2unix *.html

// recursively convert all html files in subdirectories
find . | mac2unix

Content-type: text/html


You are on page 2 of 13, other pages: 1 [2] 3 4 5 10 11 12 13
2013-04-05, 20:02:53
lfyvsb generic cheap viagra online >:-[ generic cialis online now TUExL
2013-04-05, 22:53:18
mdkbmch payday loans online NcBMsU pay day loan 1396 instant payday loans bSzECe payday loans 7446
2013-04-06, 01:33:31
jfebjhh payday loans 6327 payday loans YQmwlH pounds till payday kaUbz pay day loans 8914
2013-04-06, 06:08:07
yvyqrh payday loan %-[[[ payday loans LppFY payday loans 8]]] payday loans online qmqwL
2013-04-06, 09:59:01
bfkiooqp order viagra >:-[ cheapest place to order cialis RSkTK
2013-04-06, 23:46:42
olcbett buy viagra 1335 buy cialis online 5912
2013-04-07, 06:01:42
jzijpz how to order viagra 7502 cialis order :-O
2013-04-07, 19:42:52
pezorg viagra online gRFDSo cialis online 2939
2013-04-08, 10:31:51
ofuieq where can i buy viagra online 9601 buy cialis soft online >:-[
2013-04-09, 21:59:28
uxyztd payday loans %-[[[ pay day loans YxKYI payday loans UK 1010 payday loans 8]]]
2013-04-09, 23:29:08
pkrnaed cheap generic viagra eZyQm cheap generic cialis 1009
2013-04-10, 06:08:45
2013-04-11, 07:37:25
titobpf payday loans online BXizT pay day loan =-] payday loans 6531 payday loans HSzAlE
2013-04-11, 08:07:54
sppfpdv order viagra online LmtPaX viagra cialis online order dFZZPT
2013-04-11, 11:57:42
kvkuds instant payday loans 8146 pay day loans :-O payday advances IBPtDT payday loans mspJuu
You are on page 2 of 13, other pages: 1 [2] 3 4 5 10 11 12 13



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: