find and cp with directory structure.

David Shochat david.shochat at gmail.com
Mon Oct 24 11:00:36 UTC 2011


On Mon, Oct 24, 2011 at 6:41 AM, Wipe_Out
<wipe_out at users.sourceforge.net> wrote:
> Hi,
> I am trying to keep a directory with only the files that have changed in the
> last 30 days (nothing earlier).. I am trying this command..
> find /mnt/Scheduling/ -type f -mtime -30 -exec cp -r {}
> /home/ftpuser/attendance_registers/ \;
> I have tried with and without the "-type f" option but it only copies the
> files from all directories of the source to the root of the destination..
> Even using "cp -r" made no difference because obviously find is just passing
> the filename to the cp command..
> rsync is no good because I can't limit it to getting files that have changed
> in the last 30 days only..
> Anyone have any suggestions how I can replicate the directory structure as
> well?

Perl's File::Find module is great for this sort of thing, assuming you
know Perl.
-- David




More information about the ubuntu-users mailing list