find and cp with directory structure.
Nils Kassube
kassube at gmx.net
Mon Oct 24 11:38:56 UTC 2011
Wipe_Out wrote:
> 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..
The find command passes the filename including path, but cp only uses
the filename for the destination. If you want to copy the path as well,
you could try the "--parents" option to the cp command.
Nils
More information about the ubuntu-users
mailing list