DelphiFAQ Home Search:

Converting Mac style text files to Unix style

 

comments195 comments. Current rating: 3 stars (186 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 13 of 13, other pages: 1 2 3 10 11 12 [13]
2014-07-03, 12:09:33
online loans same day  
rating
wdwhzytb http://paydayloansqdo.com/ online loans same day HMTcAo http://paydayloansqdf.com/ instant loan today xOLkpK http://paydayloansqds.com/ instant cash loans 3843 http://paydayloansqdj.com/ magnum cash advance CPAaiy
2014-07-04, 07:01:22
magnum cash advance  
rating
xjwcubji http://paydayloansqdj.com/ magnum cash advance KkQpc http://paydayloansqds.com/ instant cash loans =-] http://paydayloansqdf.com/ instant loan today >:]] http://paydayloansqdo.com/ online loans same day ctsJZN
2014-07-04, 12:22:40
payday loans  
rating
frdtmjt http://paydayloansusaplg.com/ payday loans IUYMxT http://paydayloansqda.com/ payday loans :-O http://paydayloansnsa.com/ payday loans 4381 http://paydayloans24x7.com/ payday loans 8]]]
2014-08-03, 23:53:01
money mutual  
rating
njquzs http://paydayloansqxn.com/ money mutual 5688 http://paydayloansqxa.com/ emergency loans for bad credit 8]]] http://paydayloansqxg.com/ money mutual installment loans APrbOQ http://paydayloansqxt.com/ plain green loans ixyXn http://paydayloansqxm.com/ get a loan today 7485
2014-08-06, 00:26:31
easy payday loans  
rating
jafblw http://paydayloansqxc.com/ easy payday loans 5064 http://paydayloansqxk.com/ payday loans 4577 http://paydayloansqxh.com/ money mutual 6420 http://paydayloansqxu.com/ mobile loans 8]]] http://paydayloansqxp.com/ cash loans online >:-[
2014-08-06, 08:05:30
cash loans online  
rating
oofwkd http://paydayloansqxp.com/ cash loans online sMbsux http://paydayloansqxh.com/ money mutual 2198 http://paydayloansqxc.com/ easy payday loans 7557 http://paydayloansqxk.com/ payday loans 6058 http://paydayloansqxu.com/ mobile loans 3796
2014-08-08, 20:26:23
sameday loan  
rating
mhvjvn http://paydayloansqxj.com/ sameday loan =-] http://paydayloansqxf.com/ spot loan wEpTO http://paydayloansqxq.com/ sameday payday loans online :-O http://paydayloansqxd.com/ payday loans :-O http://paydayloansqxs.com/ money mutual 1155
2014-08-16, 23:36:50
next day loans  
rating
izsasy http://paydayloansqxb.com/ next day loans 4476 http://paydayloansqxl.com/ money mutual AwPDY http://paydayloansqxi.com/ payday loans 6410 http://paydayloansqxo.com/ payday loans >:-[ http://paydayloansqxr.com/ payday loans 9544
2014-08-18, 13:20:50
payday loans  
rating
ozdmxw http://paydayloansqxo.com/ payday loans 0737 http://paydayloansqxl.com/ money mutual :-O http://paydayloansqxi.com/ payday loans 6802 http://paydayloansqxr.com/ payday loans mvbrc http://paydayloansqxb.com/ next day loans 9542
2014-11-14, 08:28:24
payday loans  
rating
giblvfn http://paydayloanshsc.com/ payday loans 6056 http://paydayloansnsa.com/ payday loans 5370 http://paydayloanshsh.com/ payday loans >:-[ http://2012paydayloans.net/ payday loans 8785 http://paydayloansqdq.com/ payday loans 8867 http://paydayloansvmg.com/ payday loans 6551
2014-11-14, 15:53:10
mobile loans  
rating
ounbyawe http://paydayloansbrd.com/ mobile loans 8]]] http://paydayloansbri.com/ fast payday loans feFpk http://paydayloansbrf.com/ payday loans no credit check 6859
2015-02-01, 04:04:43
anonymous from Ecuador  
This piece was cogent, wetlrw-itlen, and pithy.
2015-02-12, 20:12:05
anonymous from Venezuela  
pertain http://levitrasss.net medical-related sites installing http://insurance-low.net how much erectile dysfunction http://drugustore.com many manufacturers
2015-02-12, 20:12:10
anonymous from China  
pertain http://levitrasss.net medical-related sites installing http://insurance-low.net how much erectile dysfunction http://drugustore.com many manufacturers
2015-02-13, 06:57:25
payday loans  
rating
eznrctnn http://paydayloansqdq.com/ payday loans >:]] http://paydayloansdpl.com/ payday loans 1043 http://2012paydayloans.net/ payday loans QStBXl http://paydayloansnsa.com/ payday loans %-[[[ http://paydayloansdpu.com/ payday loans 4844 http://paydayloansbra.com/ payday loans 8]]]
You are on page 13 of 13, other pages: 1 2 3 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: