DelphiFAQ Home Search:

Converting Mac style text files to Unix style

 

comments184 comments. Current rating: 3 stars (177 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 4 of 13, other pages: 1 2 3 [4] 5 6 7 10 11 12 13
2013-05-14, 18:26:54
 
rating
fmoiivlp
2013-05-16, 14:38:35
 
rating
nzbqvwzm http://paydayloansusacxd.com/ personal loans 3543 http://paydayloansc..adacxd.ca/ no fax pay day loan %-[[[ http://paydayloansu..cxd.co.uk/ payday cash MRkJqG
2013-05-16, 20:47:06
 
rating
jkplsg http://paydayloansu..cxd.co.uk/ short term loan %-[[[ http://paydayloansusacxd.com/ pay day loan kZkZtK http://paydayloansc..adacxd.ca/ no fax pay day loan 4555
2013-05-17, 12:22:57
 
rating
dnvmxf http://paydayloansu..cxg.co.uk/ Payday UK 5630 http://paydayloansusacxg.com/ payday advance AtYmx http://paydayloansc..adacxg.ca/ payday loan Canada 4207
2013-05-17, 19:19:55
 
rating
flamquda http://paydayloansu..cxg.co.uk/ online payday 6834 http://paydayloansusacxg.com/ payday loan DiXgbx http://paydayloansc..adacxg.ca/ no fax pay day loan >:]]
2013-05-18, 14:45:51
 
rating
hyfctaa http://paydayloansu..cxi.co.uk/ payday loans online 8]]] http://paydayloansusacxi.com/ fast payday loan >:-[ http://paydayloansc..adacxi.ca/ payday loan Canada 3174
2013-05-21, 23:07:09
 
rating
nrocnps http://paydayloansu..cxb.co.uk/ instant Payday Loans YxoKMB http://paydayloansusacxb.com/ payday loan oldnwn http://paydayloansc..adacxb.ca/ payday loan Alberta >:]]
2013-05-24, 13:25:25
 
rating
pftdsjzf http://paydayloansu..cxj.co.uk/ Bad Credit Loans %-[[[ http://paydayloansusacxj.com/ no fax payday loans 7953 http://paydayloansc..adacxj.ca/ pay day loan yNsrHt
2013-05-25, 04:28:14
 
rating
sfxtbbvf http://paydayloansusacxj.com/ cash advance ZkEYdR http://paydayloansc..adacxj.ca/ cash advance loans yuNnpC http://paydayloansu..cxj.co.uk/ payday loans 8275
2013-06-06, 12:23:47
payday loan  
rating
lyxudxl http://paydayloansusacxh.com/ payday loan gNBzb http://paydayloansc..adacxh.ca/ payday loan Canada 8]]] http://paydayloansu..cxh.co.uk/ Bad Credit Loans 3228
2013-06-07, 14:16:08
short term loan  
rating
lbvyci http://paydayloansu..cxf.co.uk/ short term loan Fbfnj http://paydayloansusacxf.com/ personal loans WUClEs http://paydayloansc..adacxf.ca/ payday Canada 4980
2013-06-08, 01:05:54
payday loan  
rating
dydnaj http://paydayloansusacxf.com/ payday loan >:-OOO http://paydayloansc..adacxf.ca/ no fax pay day loan >:]] http://paydayloansu..cxf.co.uk/ instant Payday Loans 8]]]
2013-06-08, 10:30:35
pounds till payday  
rating
ngzefv http://paydayloansu..cxc.co.uk/ pounds till payday pfEYOP http://paydayloansusacxc.com/ personal loans eAFMYj http://paydayloansc..adacxc.ca/ cash advances 0047
2013-06-08, 12:55:54
payday advance  
rating
vvakfyii http://paydayloansusacxc.com/ payday advance JcvxUE http://paydayloansc..adacxc.ca/ cash advances 5175 http://paydayloansu..cxc.co.uk/ pay day loans hZeZp
2013-06-10, 21:30:26
pounds till payday  
rating
jndmcd http://paydayloansu..alb.co.uk/ pounds till payday xveTZ http://paydayloansusaalb.com/ payday loans NIkGI http://paydayloansc..adaalb.ca/ payday loans Canada 9915
You are on page 4 of 13, other pages: 1 2 3 [4] 5 6 7 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: