I am searching files who have either been created or modified for the last 60 minuts. I find these via

find ~/data/ -cmin -60 -mmin -60 -type f

~ the home directory /usr/wg/

After that I want to copy these files and preserve the main folder structure... The results of the find command are for instance...


Now when I use

rsync -a `find ~/data/ -cmin -60 -mmin -60 -type f` ~/vee/

In the folder ~/vee/ I get


While I want


How do I achieve this? I looked at

  1. How to copy modified files while preserving folder structure
  2. https://serverfault.com/questions/180853/how-to-copy-file-preserving-directory-path-in-linux
  3. https://stackoverflow.com/questions/1650164/bash-copy-named-files-recursively-preserving-folder-structure

and several other answers, but I do not seem to get it right.


You should rewrite your command on this way:

cd ~/data; find . -cmin -60 -mmin -60 -type f

to be able to get from find relative paths

And maybe something like

find ...  -exec cp -r "{}" ../vee/ \; 

will do the work with copy the files with subdirectory structure

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.