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 12 of 13, other pages: 1 2 3 9 10 11 [12] 13
2014-05-08, 19:26:04
payday loans  
rating
szribio http://paydayloansith.com/ payday loans 6022 http://paydayloansitl.com/ unsecured loans online up to 1000 FrOjm http://paydayloansitq.com/ 100 day loans nFxBLW http://paydayloansitc.com/ instant loans >:-OOO
2014-05-11, 07:54:38
loans with bad credit  
rating
vhltqfd http://paydayloansiti.com/ loans with bad credit 0029 http://paydayloansitm.com/ payday loans jLBlc http://paydayloansitr.com/ money mutual 2968 http://paydayloansitd.com/ installment loans >:-OOO
2014-05-13, 10:52:16
money mutual  
rating
iswwobc http://paydayloansitr.com/ money mutual RdOtha http://paydayloansitm.com/ payday loans 3006 http://paydayloansitd.com/ installment loans :-O http://paydayloansiti.com/ loans with bad credit OnMMwS
2014-05-21, 22:02:48
payday advance  
rating
acctqa http://paydayloansito.com/ payday advance >:]] http://paydayloansitt.com/ payday loans gvLXj http://paydayloansitk.com/ pay day loans TLDAf http://paydayloansitf.com/ cash advance online :-O
2014-05-24, 18:03:13
no credit check loans  
rating
loxgly http://paydayloansqdg.com/ no credit check loans %-[[[ http://paydayloansqda.com/ online payday advance 8258 http://paydayloansqdl.com/ 90 day loans JCQfog http://paydayloansqdu.com/ payday installment loans online SZEqZB
2014-05-25, 01:52:42
payday loans  
rating
zpzyds http://paydayloansmsa.com/ payday loans %-[[[ http://paydayloansusaplg.com/ payday loans :-O http://2012paydayloans.net/ payday loans >:]] http://paydayloansusaple.com/ payday loans >:-[ http://paydayloans24x7.com/ payday loans >:-[
2014-05-26, 02:27:11
90 day loans  
rating
mzwhoh http://paydayloansqdl.com/ 90 day loans 9247 http://paydayloansqda.com/ online payday advance mFHKA http://paydayloansqdu.com/ payday installment loans online >:-OOO http://paydayloansqdg.com/ no credit check loans 9804
2014-05-31, 06:04:19
money mutual funds  
rating
rslukkvj http://paydayloansqdm.com/ money mutual funds =-] http://paydayloansqdk.com/ apply for small loans :-O http://paydayloansqdb.com/ payday installment loans YGenD http://paydayloansqdq.com/ payday loans 7966
2014-05-31, 07:26:50
payday loans  
rating
spohsrmh http://paydayloansnsa.com/ payday loans pqaBAF http://paydayloansusaprh.com/ payday loans >:-OOO http://paydayloansitm.com/ payday loans =-] http://paydayloansusaplg.com/ payday loans >:]] http://2012paydayloans.net/ payday loans 4263 http://paydayloansitt.com/ payday loans 6402 http://paydayloansmsa.com/ payday loans WDdrB http://paydayloans24x7.com/ payday loans >:-OOO
2014-06-05, 18:43:54
payday loans  
rating
fxirzm http://2012paydayloans.net/ payday loans AxlFvJ http://paydayloansmsa.com/ payday loans 5515 http://paydayloansitm.com/ payday loans VDwnaz http://paydayloansitt.com/ payday loans 8]]] http://paydayloansusaprh.com/ payday loans XQUXlk http://paydayloansusaplg.com/ payday loans >:-[ http://paydayloansnsa.com/ payday loans 2940 http://paydayloans24x7.com/ payday loans xIuvFG
2014-06-05, 21:05:34
payday loans  
rating
gocmuh http://paydayloansqdp.com/ payday loans cHINd http://paydayloansqdc.com/ online loans with no credit check 8]]] http://paydayloansqdr.com/ loans without credit check aZrCJ http://paydayloansqdh.com/ apply for fast cash 2988
2014-06-06, 19:41:31
payday loans  
rating
ejwknoh http://paydayloansqdp.com/ payday loans 7273 http://paydayloansqdh.com/ apply for fast cash eWRqb http://paydayloansqdc.com/ online loans with no credit check %-[[[ http://paydayloansqdr.com/ loans without credit check 8508
2014-06-26, 20:34:22
payday loans  
rating
zucmklze http://paydayloansusaplg.com/ payday loans %-[[[ http://paydayloansmsa.com/ payday loans tanSd http://paydayloansusaprh.com/ payday loans OVvyj http://paydayloans24x7.com/ payday loans :-O
2014-06-30, 19:19:04
payday loans  
rating
kecuvt http://paydayloans24x7.com/ payday loans ExzIoF http://paydayloansnsa.com/ payday loans >:-[ http://2012paydayloans.net/ payday loans DPmLu http://paydayloansusaplg.com/ payday loans 7505
2014-07-01, 12:31:09
instant loan today  
rating
natdhdi http://paydayloansqdf.com/ instant loan today %-[[[ http://paydayloansqdj.com/ magnum cash advance >:]] http://paydayloansqds.com/ instant cash loans 0428 http://paydayloansqdo.com/ online loans same day %-[[[
You are on page 12 of 13, other pages: 1 2 3 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: