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 2 of 13, other pages: 1 [2] 3 4 5 10 11 12 13
2013-04-05, 20:02:53
 
rating
lfyvsb http://genericviagradsb.com/ generic cheap viagra online >:-[ http://genericcialisdsb.com/ generic cialis online now TUExL
2013-04-05, 22:53:18
 
rating
mdkbmch http://paydayloansa..iadsb.com/ payday loans online NcBMsU http://paydayloansc..adadsb.ca/ pay day loan 1396 http://paydayloansusadsb.com/ instant payday loans bSzECe http://paydayloansu..dsb.co.uk/ payday loans 7446
2013-04-06, 01:33:31
 
rating
jfebjhh http://paydayloansa..iafsj.com/ payday loans 6327 http://paydayloansusafsj.com/ payday loans YQmwlH http://paydayloansu..fsj.co.uk/ pounds till payday kaUbz http://paydayloansc..adafsj.ca/ pay day loans 8914
2013-04-06, 06:08:07
 
rating
yvyqrh http://paydayloansusafsj.com/ payday loan %-[[[ http://paydayloansc..adafsj.ca/ payday loans LppFY http://paydayloansu..fsj.co.uk/ payday loans 8]]] http://paydayloansa..iafsj.com/ payday loans online qmqwL
2013-04-06, 09:59:01
 
rating
bfkiooqp http://orderviagradsb.com/ order viagra >:-[ http://ordercialisdsb.com/ cheapest place to order cialis RSkTK
2013-04-06, 23:46:42
 
rating
olcbett http://buyviagrafsc.com/ buy viagra 1335 http://buycialisfsc.com/ buy cialis online 5912
2013-04-07, 06:01:42
 
rating
jzijpz http://orderviagradsb.com/ how to order viagra 7502 http://ordercialisdsb.com/ cialis order :-O
2013-04-07, 19:42:52
 
rating
pezorg http://viagraonlinefsc.com/ viagra online gRFDSo http://cialisonlinefsc.com/ cialis online 2939
2013-04-08, 10:31:51
 
rating
ofuieq http://buyviagrafsc.com/ where can i buy viagra online 9601 http://buycialisfsc.com/ buy cialis soft online >:-[
2013-04-09, 21:59:28
 
rating
uxyztd http://paydayloansusadsa.com/ payday loans %-[[[ http://paydayloansc..adadsa.ca/ pay day loans YxKYI http://paydayloansu..dsa.co.uk/ payday loans UK 1010 http://paydayloansa..iadsa.com/ payday loans 8]]]
2013-04-09, 23:29:08
 
rating
pkrnaed http://cheapviagrafsc.com/ cheap generic viagra eZyQm http://cheapcialisfsc.com/ cheap generic cialis 1009
2013-04-10, 06:08:45
 
rating
2013-04-11, 07:37:25
 
rating
titobpf http://paydayloansa..iadsc.com/ payday loans online BXizT http://paydayloansc..adadsc.ca/ pay day loan =-] http://paydayloansusadsc.com/ payday loans 6531 http://paydayloansu..dsc.co.uk/ payday loans HSzAlE
2013-04-11, 08:07:54
 
rating
sppfpdv http://orderviagrafsc.com/ order viagra online LmtPaX http://ordercialisfsc.com/ viagra cialis online order dFZZPT
2013-04-11, 11:57:42
 
rating
kvkuds http://paydayloansusadsc.com/ instant payday loans 8146 http://paydayloansc..adadsc.ca/ pay day loans :-O http://paydayloansu..dsc.co.uk/ payday advances IBPtDT http://paydayloansa..iadsc.com/ payday loans mspJuu
You are on page 2 of 13, other pages: 1 [2] 3 4 5 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: