Answer the question
In order to leave comments, you need to log in
How to find and recursively copy files on debian?
Faced a problem. Trying to copy only new files recursively to another directory. I got to this line:
find /dir1 -mtime -1 | xargs cp -t /dir2/;
But the problem is that some files may be in subfolders (for example /dir1/folder1/folder2) then they need to be copied to /dir2/folder1/folder2, but everything is copied to the heap, i.e. to /dir2
Using with the -r switch copies all files in general (regardless of their modification date). Who will tell you what is wrong?
Answer the question
In order to leave comments, you need to log in
You should use not naked find, but find + rsync (examples are easy to google).
Here is an example
find /home/bitrix/ext_www/shop.wildorchid.ru/ -regex ".*\.\(jpg\|jpeg\|gif\|png\|JPG\|JPEG\|GIF\|PNG\)" -print0 | xargs -0 cp --parents --target-directory ./tmp/backup
-mmin
or -mtime
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question