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 3 of 13, other pages: 1 2 [3] 4 5 6 10 11 12 13
2013-04-15, 10:50:23
 
rating
gwbdpf http://paydayloansa..iadsd.com/ payday loans 9584 http://paydayloansc..adadsd.ca/ pay day loans 8366 http://paydayloansusadsd.com/ instant payday loans 0185
2013-04-15, 14:52:14
 
rating
wkhityye http://paydayloansu..dsd.co.uk/ same day loan NQEplc http://paydayloansa..iadsd.com/ payday loans =-] http://paydayloansusadsd.com/ payday advance 7801 http://paydayloansc..adadsd.ca/ payday loans online >:-OOO
2013-04-16, 06:29:39
 
rating
ztgfhtq http://genericviagrafsc.com/ generic viagra uBymr http://genericcialisfsc.com/ generic cialis online YQSkFx
2013-04-16, 07:20:14
 
rating
hiayumwz http://genericviagrafsc.com/ generic viagra DTpuTI http://genericcialisfsc.com/ generic cialis 2781
2013-04-16, 15:16:05
 
rating
espalgmc http://genericviagrafsc.com/ generic viagra online MbovKx http://genericcialisfsc.com/ generic cheap cialis =-]
2013-04-16, 21:49:12
 
rating
gnyjdtv http://orderviagrafsc.com/ viagra order cheap bbgCF http://ordercialisfsc.com/ cialis line order 2819
2013-04-17, 01:48:20
 
rating
chxpjd http://orderviagrafsc.com/ order 50mg viagra 9288 http://ordercialisfsc.com/ cialis line order 4618
2013-04-19, 10:34:09
 
rating
dhbrupjm http://genericviagrafsc.com/ generic viagra %-[[[ http://genericcialisfsc.com/ generic cialis 8]]]
2013-04-19, 19:37:19
 
rating
lciubmk http://paydayloansu..dsg.co.uk/ same day loan HrMyzl http://paydayloansusadsg.com/ personal loans 1685 http://paydayloansc..adadsg.ca/ payday loan Alberta vjvJKG http://paydayloansa..iadsg.com/ payday loans %-[[[
2013-04-28, 00:46:45
 
rating
dtdqxmju http://paydayloansu..pwa.co.uk/ Bad Credit Loans NCyhRR http://paydayloansusapwa.com/ no fax payday loans %-[[[ http://paydayloansusapwa.ca/ pay day loans 9181 http://paydayloansa..iapwa.com/ payday loans %-[[[
2013-04-29, 13:19:54
 
rating
ilqtcdzo http://paydayloansu..pwb.co.uk/ quickquid >:]] http://paydayloansusapwb.com/ payday loan 8]]] http://paydayloansusapwb.ca/ pay day loan IXOGN http://paydayloansa..iapwb.com/ payday loans online %-[[[
2013-04-29, 20:12:40
 
rating
bvmgybf http://paydayloansu..pwb.co.uk/ Bad Credit Loans PWAmf http://paydayloansa..iapwb.com/ payday loans australia =-] http://paydayloansusapwb.com/ quick payday loans 4582 http://paydayloansusapwb.ca/ payday Canada 6775
2013-04-29, 22:32:44
 
rating
sdyavqre http://paydayloansusapwb.com/ payday loans :-O http://paydayloansusapwb.ca/ pay day loans :-O http://paydayloansu..pwb.co.uk/ payday advances 2511 http://paydayloansa..iapwb.com/ payday loans NLfyU
2013-04-30, 16:55:49
 
rating
rbylwg http://paydayloansu..pwc.co.uk/ online payday hFlNl http://paydayloansa..iapwc.com/ payday loans dJEVq http://paydayloansusapwc.com/ personal loans :-O http://paydayloansusapwc.ca/ payday loans Canada :-O
2013-04-30, 19:11:07
 
rating
You are on page 3 of 13, other pages: 1 2 [3] 4 5 6 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: