find and cp with directory structure.

Hal Burgiss hal at burgiss.net
Mon Oct 24 17:42:23 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?
>
> TIA
>
> --
> ubuntu-users mailing list
> ubuntu-users at lists.ubuntu.com
> Modify settings or unsubscribe at:
> https://lists.ubuntu.com/mailman/listinfo/ubuntu-users
>
>

Doesn't the -a option do that ...

 $ find . -mtime +30 -exec cp -av {} $dirname/  \;

That seems to work on my system.


-- 
Hal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20111024/f55785b2/attachment.html>


More information about the ubuntu-users mailing list