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

Comments:

You are on page 1 of 13, other pages: [1] 2 3 4 10 11 12 13
2012-12-12, 04:18:41
anonymous from Germany  
/* html_preloader.js
* version 0.1, Sept 5th, 2012
* by @dazwiafl
*/

(function($) {

$.html_preloader = function(element, options) {

var defaults = {
    callback:null,
    dontAutoStartSecondCyclus: false
}

var plugin = this,
    __ABSOLUTE_PATH = '',
    __VERSION = '0712120200';

plugin.settings = {
};

var $element = $(element),
element = element,
filelist = new Array(
                'img/assets/items/animations/tutor/tutor_waving_2.png',
                'img/assets/items/animations/tutor/tutor_intro.png',
                'img/assets/items/animations/tutor/tutor_success.png',
                'img/assets/items/animations/lady/lady_intro.png',
                'img/assets/items/animations/lady/lady_success.png',
                'img/assets/items/animations/prof/prof_success.png',
                'img/assets/items/animations/prof/prof_chillin.png',
                'img/assets/items/animations/prof/prof_waving.png',
                'img/assets/items/animations/hippie/hippie_chillin.png',
                'img/decoration/page-2-character-ludwig.png',
                'img/decoration/page-2-footer-flower-unexpl.png',
                'img/decoration/page-2-footer-flower.png',
                'img/decoration/page-2-footer-right-unexpl.png',
                'img/decoration/page-2-footer-right.png',
                'img/decoration/page-2-header-background-ludwig.jpg',
                'img/decoration/page-2-header-deco-1.png',
                'img/decoration/page-2-speachbubble-ludwig.png',
                'img/decoration/page-3-finalized-unexpl.png',
                'img/decoration/page-3-finalized.png',
                'img/decoration/page-3-footer-background-unexpl.png',
                'img/decoration/page-3-footer-background.png',
                'img/decoration/page-3-header-decoration-unexpl.png',
                'img/decoration/page-3-header-decoration.png',
                'img/decoration/page-3-speachbubble-header.png',
                'img/decoration/page-3-speachbubble-library.png',
                'img/decoration/page-3-speachbubble-studygroup.png',
                'img/decoration/page-3-speachbubble-header-unexpl.png',
                'img/decoration/page-3-speachbubble-library-unexpl.png',
                'img/decoration/page-3-speachbubble-studygroup-unexpl.png',
                'img/animations/anim-obtained/anim-obtained-background.png',
                'img/decoration/page-arrow-left-background.png',
                'img/decoration/page-arrow-left-unexpl.png',
                'img/decoration/page-arrow-left.png',
                'img/decoration/page-arrow-right-background.png',
                'img/decoration/page-arrow-right-unexpl.png',
                'img/decoration/page-arrow-right.png',
                'img/decoration/page1-footer-deco1-unexpl.png',
                'img/decoration/page-1-info-icon.png',
                'img/decoration/page1-footer-deco1.png',
                'img/decoration/page1-footer-deco2-unexpl.png',
                'img/decoration/page1-footer-deco2.png',
                'img/decoration/page1-footer-deco3-unexpl.png',
                'img/decoration/page1-footer-deco3.png',
                'img/ui/book-icons.png',
                'img/ui/info-dialog-inner-icon.png',
                'img/ui/info-dialog-x-btn.png',
                'img/ui/clock-background.png',
                'img/ui/default-player-icon.jpg',
                'img/ui/dialog-bubble-arrow.png',
                'img/ui/dialog-button.png',
                'img/ui/dialog-clickcatcher.png',
                'img/ui/drag-and-drop-game-draggable-view-background.png',
                'img/ui/find-and-drag-game-checkbtn.png',
                'img/ui/find-and-drag-game-drag-area-background.png',
                'img/ui/find-and-drag-game-drop-cancel-btn.png',
                'img/ui/little-tick.png',
               
                'img/ui/little-x.png',
               
                'img/ui/live-active.png',
               
                'img/ui/live-inactive.png',
               
                'img/ui/logo-small.png',
               
                'img/ui/mc-game-answer-hover-left.png',
               
                'img/ui/mc-game-answer-hover-middle.png',
               
                'img/ui/mc-game-answer-hover-right.png',
               
                'img/ui/mc-game-answer-neutral-left.png',
                'img/ui/mc-game-answer-neutral-middle.png',
                'img/ui/mc-game-answer-neutral-right.png',
                'img/ui/mc-game-answer-right-left.png',
                'img/ui/mc-game-answer-right-middle.png',
                'img/ui/mc-game-answer-right-right.png',
                'img/ui/mc-game-answer-wrong-left.png',
                'img/ui/mc-game-answer-wrong-middle.png',
                'img/ui/mc-game-answer-wrong-right.png',
                'img/ui/memory-background.jpg',
                'img/ui/notification-no.png',
                'img/ui/notification-yes.png',
                'img/ui/really-background.png',
                'img/ui/rgba0000.png',
                'img/ui/rgba00050.png',
                'img/ui/rgba00060.png',
                'img/ui/rgba25525525550.png',
                'img/ui/rgba25525525570.png',
                'img/ui/share-btn.png',
                'img/ui/single-decision-bubble-arrow.png',
                'img/ui/small-no-btn.png',
                'img/ui/small-yes-btn.png',
                'img/ui/subgame-bake-button.png',
                'img/ui/subgame-dialog-background-pattern.png',
                'img/ui/subgame-dialog-button.png',
                'img/ui/subgame-empty-btn.png',
                'img/ui/subgame-fail-dialog-background-pattern.png',
                'img/ui/subgame-won-dialog-background-pattern.png',
                'img/ui/subgame-wonfail-dialog-button.png',
                'img/ui/rewards/rb-flower1.png',
                'img/ui/rewards/rb-flower10.png',
                'img/ui/rewards/rb-flower11.png',
                'img/ui/rewards/rb-flower12.png',
                'img/ui/rewards/rb-flower13.png',
                'img/ui/rewards/rb-flower2.png',
                'img/ui/rewards/rb-flower3.png',
                'img/ui/rewards/rb-flower4.png',
                'img/ui/rewards/rb-flower5.png',
                'img/ui/rewards/rb-flower6.png',
                'img/ui/rewards/rb-flower7.png',
                'img/ui/rewards/rb-flower8.png',
                'img/ui/rewards/rb-flower9.png',
                'img/Characters/lady-dialog.png',
                'img/Characters/ludwig-dialog.png',
                'img/decoration/abi-book.png',
                'img/decoration/abi-mag.png',
                'img/decoration/finger-hand-icon-cursor.png',
                'img/decoration/page-1-abi-background-unexpl.png',
                'img/decoration/page-1-abi-background.png',
                'img/decoration/page-1-lovepeace-unexpl.png',
                'img/decoration/page-1-lovepeace.png',
                'img/decoration/page-1-poow-unexpl.png',
                'img/decoration/page-1-poow.png',
                'img/decoration/page-1-pow-unexpl.png',
                'img/decoration/page-1-pow.png',
                'img/decoration/page-1-speachbubble-1-unexpl.png',
                'img/decoration/page-1-speachbubble-1.png',
                'img/decoration/page-1-speachbubble-2-unexpl.png',
                'img/decoration/page-1-speachbubble-2.png',
                'img/decoration/page-1-stars-unexpl.png',
                'img/decoration/page-1-stars.png',
                'img/assets/items/overlays/hs-nawi-char.png',
                'img/assets/items/overlays/hs-tech-char.png',
                'img/assets/items/overlays/hs-med-char.png',
                'img/assets/items/overlays/hs-maslow-char.png',
                'img/assets/items/overlays/hs-art-char.png',
    'img/assets/items/speach-bubble-icon.png',
                'img/assets/items/zumjugendzimmer-text.png',
                'img/assets/items/zumjugendzimmer.png',
                'img/assets/items/zurimmat-text.png',
                'img/assets/items/zurimmat.png',
                'img/assets/jugendzimmer/bPDQUu.png',
                'img/assets/jugendzimmer/BU5QuW.png',
                'img/assets/jugendzimmer/G6F7cH.png',
                'img/assets/jugendzimmer/gLcW79.png',                
                'img/assets/jugendzimmer/HzWPAM.png',
                'img/assets/jugendzimmer/JMjYEv.png',
                'img/assets/jugendzimmer/K9bTE4.png',
                'img/assets/jugendzimmer/QhmbTe.png',
                'img/assets/jugendzimmer/TRfUyt.png',
                'img/assets/jugendzimmer/YHqFT9.png',
                'img/assets/items/abi-de-buch.png',
                'img/assets/items/abi-de-mag.png',
                'img/assets/items/jugendzimmer-antrag.png',
                'img/assets/items/jugendzimmer-driving.png',
                'img/assets/items/zurparty.png',
                'img/assets/items/zurpartytext.png',
                'img/assets/items/jugendzimmer-perso.png',
                'img/assets/items/jugendzimmer-teddy.png',
                'img/assets/items/jugendzimmer-vita.png',
                'img/assets/items/jugendzimmer-wallet.png',
                'img/assets/items/jugendzimmer-wasser.png',
                'img/assets/items/jugendzimmer-zeugnis.png',
                'img/assets/items/start-game-entrance.png',
                'img/assets/items/start-game-jugendzimmer.png',
                'img/assets/items/start-game-experiment.png',
                'img/assets/items/start-game-tor.png',
                'img/animations/anim-obtained/anim-flower1.png',
                'img/animations/anim-obtained/anim-flower2.png',
                'img/animations/anim-obtained/anim-flower3.png',
                'img/animations/timer/subgame-timer-animation.png',
                'img/abi-de-button.png',
                'img/bibliothek.jpg',
                'img/entrance.jpg',
                'img/entrance2.jpg',
                'img/logo.jpg',
                'img/questionmark.jpg',
                'img/register.jpg',
                'img/room.jpg',
    'img/decoration/page-2-info-icon.png',
    'img/decoration/page-3-info-icon.png',
                'img/assets/items/start-game-kitchen.png',
                'img/assets/items/start-game-kunst.png',
                'img/assets/items/start-game-law.png',
                'img/assets/items/start-game-library.png',
                'img/assets/items/start-game-literature.png',
                'img/assets/items/start-game-maslow.png',
                'img/assets/items/start-game-medizin.png',
                'img/assets/items/start-game-study-group.png',
                'img/assets/items/start-game-technic.png',
    'img/studygroup_1.jpg',
    'img/studygroup_2.jpg',
                'img/party.jpg',
                'img/hs-bwl.jpg',
                'img/hs-geo.jpg',
                'img/hs-ingenieur.jpg',
                'img/hs-kultur.jpg',
                'img/hs-kunst.jpg',
                'img/hs-medizin.jpg',
                'img/hs-nawi.jpg',
                'img/kitchen.jpg'
),
secondaryFiles = new Array(
    'img/decoration/party.png',
    'img/assets/items/kitchen-people.png',
    'img/assets/items/animations/party/lights.png',
    'img/assets/items/animations/party/ballon-single.png',
    'img/assets/items/animations/party/ballon-bash.png',
    'img/assets/items/animations/party/hippie.png',
    'img/assets/items/animations/party/tutor.png',
    'img/assets/items/animations/party/schorfe.png',
    'img/assets/items/animations/party/asian.png',
    'img/assets/items/animations/party/ballon-lp.png',
                'img/Characters/prof-dialog.png',
                'img/animations/anim-obtained/anim-flower10.png',
                'img/animations/anim-obtained/anim-flower11.png',
                'img/animations/anim-obtained/anim-flower12.png',
                'img/animations/anim-obtained/anim-flower13.png',
                'img/animations/anim-obtained/anim-flower4.png',
                'img/animations/anim-obtained/anim-flower5.png',
                'img/animations/anim-obtained/anim-flower6.png',
                'img/animations/anim-obtained/anim-flower7.png',
                'img/animations/anim-obtained/anim-flower8.png',
                'img/animations/anim-obtained/anim-flower9.png',
                'img/animations/anim-obtained/anim-chain.png',
                'img/assets/Buecherei/foreground.png',
                'img/assets/Buecherei/pxmap.png',
                'img/assets/Hoersaal-Kunst/bovecu.jpg',
                'img/assets/Hoersaal-Kunst/cekncu.jpg',
                'img/assets/Hoersaal-Kunst/frwacu.jpg',
                'img/assets/Hoersaal-Kunst/gostcu.jpg',
                'img/assets/Hoersaal-Kunst/renacu.jpg',
                'img/assets/Hoersaal-Maslow/blackboard.jpg',
                'img/assets/Hoersaal-Technic/2qD8JL.png',
                'img/assets/Hoersaal-Technic/6Ykk7a.png',
                'img/assets/Hoersaal-Technic/GCB2W4.png',
                'img/assets/Hoersaal-Technic/HszSmy.png',
                'img/assets/Hoersaal-Technic/N7Vs9V.png',
                'img/assets/Hoersaal-Technic/SgAwWS.png',
                'img/assets/Hoersaal-Technic/WzhE38.png',
                'img/assets/Hoersaal-Technic/zJGmbJ.png',
                'img/assets/items/studygroup_small.png',
                'img/assets/Lab/bear-drag.png',
                'img/assets/Lab/bear-show.png',
                'img/assets/Lab/bunsen-drag.png',
                'img/assets/Lab/bunsen-show.png',
                'img/assets/Lab/k2co3-drag.png',
                'img/assets/Lab/k2co3-show.png',
                'img/assets/Lab/lab-table-overlay.png',
                'img/assets/Lab/lab-table.png',
                'img/assets/Lab/tube-drag.png',
                'img/assets/Lab/tube-show.png',
                'img/assets/Lab/experiment-anim/anim-explo.png',
                'img/assets/Lab/experiment-anim/anim-fire-tube-2.png',
                'img/assets/Lab/experiment-anim/anim-fire-tube.png',
                'img/assets/Lab/experiment-anim/anim-fire.png',
                'img/assets/Lab/experiment-anim/anim-smoke.png',
                'img/assets/Party-Blumenkranz/flower1.png',
                'img/assets/Party-Blumenkranz/flower10.png',
                'img/assets/Party-Blumenkranz/flower11.png',
                'img/assets/Party-Blumenkranz/flower12.png',
                'img/assets/Party-Blumenkranz/flower13.png',
                'img/assets/Party-Blumenkranz/flower2.png',
                'img/assets/Party-Blumenkranz/flower3.png',
                'img/assets/Party-Blumenkranz/flower4.png',
                'img/assets/Party-Blumenkranz/flower5.png',
                'img/assets/Party-Blumenkranz/flower6.png',
                'img/assets/Party-Blumenkranz/flower7.png',
                'img/assets/Party-Blumenkranz/flower8.png',
                'img/assets/Party-Blumenkranz/flower9.png',
                'img/assets/Party-Blumenkranz/background.png',
                'img/assets/Pizza/ANfbwP-layer.png',
                'img/assets/Pizza/ANfbwP-small.png',
                'img/assets/Pizza/ANfbwP-thumb.png',
                'img/assets/Pizza/background.png',
                'img/assets/Pizza/Bky6HN-layer.png',
                'img/assets/Pizza/Bky6HN-small.png',
                'img/assets/Pizza/Bky6HN-thumb.png',
                'img/assets/Pizza/cF7tqX-layer.png',
                'img/assets/Pizza/cF7tqX-small.png',
                'img/assets/Pizza/cF7tqX-thumb.png',
                'img/assets/Pizza/face1.png',
                'img/assets/Pizza/face2.png',
                'img/assets/Pizza/face3.png',
                'img/assets/Pizza/face4.png',
                'img/assets/Pizza/jk67Jh-layer.png',
                'img/assets/Pizza/jk67Jh-small.png',
                'img/assets/Pizza/jk67Jh-thumb.png',
                'img/assets/Pizza/KpHk2R-layer.png',
                'img/assets/Pizza/KpHk2R-small.png',
                'img/assets/Pizza/KpHk2R-thumb.png',
                'img/assets/Pizza/MjBP8R-layer.png',
                'img/assets/Pizza/MjBP8R-small.png',
                'img/assets/Pizza/MjBP8R-thumb.png',
                'img/assets/Pizza/Ru64zU-layer.png',
                'img/assets/Pizza/Ru64zU-small.png',
                'img/assets/Pizza/Ru64zU-thumb.png',
                'img/assets/Pizza/st5NHG-layer.png',
                'img/assets/Pizza/st5NHG-small.png',
                'img/assets/Pizza/st5NHG-thumb.png'
            ),
alreadyLoaded = 0,
secAlreadyLoaded = 0,
__hitCounter = 0,
__endHitCounter = 4,
__dotIntID;

plugin.init = function() {

plugin.settings = $.extend(plugin.settings, defaults, options);

plugin.settings.clickEventHandler = getQualifiedClickHandler();
           
$element.append('<div><div id='loaderimage'></div><div id='preloaderanimationbackground'></div><div id='prel-overlay'><div id='preloaderanimation'></div><did= 'preloaderforeground'><p></p></div>&l;</div>');

__dotIntID = setInterval(function(){
    if($('#preloaderforeground p').html()==''){
        $('#preloaderforeground p').html('.');
                    return;        
    }
   
    if($('#preloaderforeground p').html()=='.'){
        $('#preloaderforeground p').html('..');
                    return;        
    }
   
        if($('#preloaderforeground p').html()=='..'){
        $('#preloaderforeground p').html('...');
                    return;        
    }
   
    if($('#preloaderforeground p').html()=='...'){
        $('#preloaderforeground p').html('');
                    return;        
    }
}, 250);

$('<img>')
    .load(function(){
        $element.find('#loaderimage').append($(this));
        hitStartPreload();
    })
    .attr('src', 'img/logo.jpg');


$element.find('#preloaderanimation').ui_animation({
    frame:{
        width: 122,
        height: 122
    },
            fps: 1,
            framecount: 100,
            image: 'img/preloader/prel.png',
            jsondriven: true,
            json: 'img/preloader/prel.json',
            stopOnStart: true,
            onReady: function(){ hitStartPreload(); }
});

$('<img>')
    .load(function(){
        $element.find('#preloaderanimationbackground').append($(this));
        hitStartPreload();
    })
    .attr('src', 'img/preloader/bg.png');
   
$('<img>')
    .load(function(){
        $element.find('#preloaderforeground').prepend($(this));
        hitStartPreload();
    })
    .attr('src', 'img/preloader/fg.png');
        };
       
        plugin.startSecondCyclus = function(){
           
            if(alreadyLoaded != filelist.length){
                plugin.settings.dontAutoStartSecondCyclus = false;
                return;
            }

            secondaryPreload();
        };
       
        var hitStartPreload = function(){
            __hitCounter++;
           
            if(__hitCounter == __endHitCounter){
                if(plugin.settings.onReady)
                    plugin.settings.onReady();
                setTimeout(function(){startPreload();}, 250);
            }
        };
       
        var startPreload = function(){
            for(var i = 0; i < filelist.length; i++){
                loadFile(filelist[i], true);
            }
}

var secondaryPreload = function(){
    for(var i = 0; i < secondaryFiles.length; i++)
                loadFile(secondaryFiles[i], false);
}

        var loadFile = function(fn, primaryFile){
            var img = new Image();
            $(img)
                .load(function(){
                    $(this).remove();
                    if(primaryFile)
                        onItemLoaded();
                    else
                        onSecondaryItemLoaded();
                })
                .attr('src', __ABSOLUTE_PATH+fn+'?v='+__VERSION);
        }
       
        var onItemLoaded = function(){
            alreadyLoaded++;
           
            clearInterval(__dotIntID);
           
            var sc = Math.floor(100/(filelist.length-1)*alreadyLoaded);
            $('#preloaderanimation').data('ui_animation').gotoAndStop(sc);
            $('#preloaderforeground p').html(sc+'%');
           
            if(alreadyLoaded == filelist.length){
                finished();
                if(!plugin.settings.dontAutoStartSecondCyclus)
                    secondaryPreload();
            }
        }
       
        var onSecondaryItemLoaded = function(){
            secAlreadyLoaded++;
            if(secAlreadyLoaded == secondaryFiles.length)
                $element.remove();
        }
       
        var finished = function(){
            if(plugin.settings.callback)
                plugin.settings.callback();
        };
       
plugin.init();

}

$.fn.html_preloader = function(options) {

return this.each(function() {

if (undefined == $(this).data('html_preloader')) {

var plugin = new $.html_preloader(this, options);

$(this).data('html_preloader', plugin);

}

});

}

})(jQuery);
2013-01-08, 18:48:11
anonymous from China  
2013-03-05, 07:31:35
 
rating
ivwnew
2013-03-06, 08:10:44
 
rating
ygcxvr
2013-03-09, 21:11:03
 
rating
kbjpal
2013-04-01, 18:09:54
 
rating
fyhpte http://cheapviagradsb.com/ viagra cheap NQrmmy http://cheapcialisdsb.com/ cheap cialis bCwzlE
2013-04-02, 02:27:34
 
rating
gbccriy http://viagraonlinedsb.com/ viagra online >:-[ http://cialisonlinedsb.com/ cialis online HAGSBq
2013-04-02, 06:42:22
 
rating
rbvkywky http://genericviagradsc.com/ generic viagra fSqfgH http://genericcialisdsc.com/ generic cialis 3840
2013-04-02, 16:48:57
 
rating
jvldocr http://buyviagradsb.com/ viagra 1620 http://buycialisdsb.com/ buy cialis delived next day ulWUDI
2013-04-02, 18:07:26
 
rating
qprnxbb http://paydayloansu..fsh.co.uk/ payday loans %-[[[ http://paydayloansusafsh.com/ instant payday loans :-O http://paydayloansc..adafsh.ca/ pay day loan >:-[ http://paydayloansa..iafsh.com/ payday loans 6261
2013-04-02, 22:18:16
 
rating
vndvjhb http://buyviagradsb.com/ buy viagra iwLnU http://buycialisdsb.com/ buy generic cialis >:-[
2013-04-03, 16:09:55
 
rating
rgcgdzv http://paydayloansa..iafsh.com/ payday loans australia >:-OOO http://paydayloansusafsh.com/ payday loans online 1073 http://paydayloansu..fsh.co.uk/ instant Payday Loans dHmHml http://paydayloansc..adafsh.ca/ payday loans Asyzt
2013-04-03, 16:48:28
 
rating
quhtlu http://viagraonlinedsb.com/ viagra online JGQFXE http://cialisonlinedsb.com/ cialis online =-]
2013-04-04, 02:00:43
 
rating
xljmzfdb http://genericviagradsc.com/ generic cheap viagra 0296 http://genericcialisdsc.com/ generic cialis online LuOKyr
2013-04-05, 09:15:03
 
rating
wortoux http://paydayloansusafsj.com/ cash advance >:-[ http://paydayloansc..adafsj.ca/ payday loans 2402 http://paydayloansu..fsj.co.uk/ Quick Quid 8772 http://paydayloansa..iafsj.com/ payday loans australia >:-OOO
You are on page 1 of 13, other pages: [1] 2 3 4 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: