Results 1 to 3 of 3

Thread: Alternative to Ditto

  1. #1
    Join Date
    Jul 2006
    Location
    Minneapolis, MN
    Beans
    8
    Distro
    Ubuntu 5.10

    Question Alternative to Ditto

    Hello! I'm in a bit of a pickle porting over a shell script from OS X to Linux. Specifically, I used the ditto command while looping through a list of full file paths. For instance, if my list were;

    /etc/bind/zones/db.domain.private
    /etc/warning
    /etc/cron.daily/script.sh

    I could ditto each one to a backup directory like so;

    ditto /etc/bind/zones/db.domain.private ~/backup/etc/bind/zones/db.domain.private
    ditto /etc/warning ~/backup/etc/warning
    ditto /etc/cron.daily/script.sh ~/backup/etc/cron.daily/script.sh

    And, there you have it, I'd have a backup of all the files in my filesystem with with their entire enclosing paths copied over, too. No complaints of directories not existing, or anything like that. As far as I can tell, Linux hasn't got a ditto, so I have tried cp with a few tags and I just can't seem to reproduce this. Can anyone give me a tip for proper syntax? Or an alternative command that could accomplish the same thing?

    Thanks!

  2. #2
    Join Date
    Feb 2009
    Location
    Dallas, TX
    Beans
    6,953
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Alternative to Ditto

    Hi sivacrom.

    Take a look at rsync.

    Let us know how it goes.
    Regards.

  3. #3
    Join Date
    Jul 2006
    Location
    Minneapolis, MN
    Beans
    8
    Distro
    Ubuntu 5.10

    Re: Alternative to Ditto

    I know rsync well. I'm using it in more than one part of the same script, as a matter of fact.

    But I found the answer I wanted, and it was this;

    cp -Rp --parents /etc/bind/zones/db.domain.private ~/backup
    cp -Rp --parents /etc/warning ~/backup
    cp -Rp --parents /etc/cron.daily/script.sh ~/backup

    My Google fu is better than I gave myself credit for.

    Sorry everyone!

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •