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.

Question:


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?

Answer:


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

Comments:

You are on page 11 of 13, other pages: 1 2 3 8 9 10 [11] 12 13
2014-01-28, 06:42:43
fast cash advance  
rating
2014-02-01, 10:30:53
payday loans  
rating
etntqv http://paydayloansusaplg.com/ payday loans >:-OOO http://paydayloansusatrj.com/ payday loans >:-[ http://paydayloansnsa.com/ payday loans %-[[[ http://usapaydayloans24.com/ payday loans >:]]
2014-02-08, 11:03:16
quick quid  
rating
zcazown http://paydayloansu..pre.co.uk/ quick quid AMktOd http://paydayloansusapre.com/ payday advance :-O http://paydayloansusaprg.com/ payday loans KFEZLx
2014-02-09, 12:36:01
pay day loan  
rating
2014-02-24, 22:30:02
payday loans  
rating
yvucmkg http://paydayloansnsa.com/ payday loans %-[[[ http://paydayloansusatrj.com/ payday loans bSwUbN http://paydayloansusaplg.com/ payday loans HSPau http://paydayloansmsa.com/ payday loans zFJLL http://2012paydayloans.net/ payday loans 2118
2014-02-26, 09:24:00
payday loans online  
rating
lajauq http://paydayloansusaprf.com/ payday loans online HdnqRZ http://paydayloansu..pri.co.uk/ quickquid 6716 http://paydayloansusapri.com/ short term loans Qaxuwa
2014-03-15, 05:13:17
http://dotcomrepublic.com/cialis-daily-dose  
rating
2014-03-24, 14:19:47
payday loans  
rating
2014-04-04, 09:50:28
payday loans online  
rating
cjnbwgc http://paydayloansusaprh.com/ payday loans online pSSTl http://paydayloansnsa.com/ instant loans >:]] http://paydayloansusaplg.com/ payday loans 5459 http://2012paydayloans.net/ payday loans :-O http://paydayloans24x7.com/ payday loans 1691
2014-04-07, 13:01:48
cialis  
rating
2014-04-08, 19:42:06
free viagra order online  
rating
2014-04-15, 04:32:47
viagra online  
rating
2014-04-15, 12:15:34
generic cialis  
rating
2014-04-16, 12:33:44
cheap viagra online  
rating
znuvce http://cheapviagraffd.com/ cheap viagra online 8]]] http://genericcialisffd.com/ generic cialis soft online tasrDr http://buycialisffd.com/ http://buycialisffd.com/ 5927 http://genericviagraffd.com/ generic viagra online 7500 http://cialisonlineffd.com/ buy cialis online %-[[[ http://viagraonlineffd.com/ viagra online kxOcG
2014-04-24, 01:46:01
http://enzymedevelopment.com/viagra-canada-pharmacy/  
rating
You are on page 11 of 13, other pages: 1 2 3 8 9 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: