问题
I would like to find files with size less than 10Mb and copy them to a different folder. I have a unix command but it's not conserving folders, just copying files:
find . -size -10Mb -exec cp {} /Users/bernardo/Desktop/copia \;
回答1:
-exec cp -p --parents -t/Users/bernardo/Desktop/copia/ {} +
The key part is --parents, to mirror the directory structure. I used -p to preserve mode, timestamp, and ownership. I find -exec {} + more intuitive than -exec {} ;, but it doesn't matter here, beyond the need to reorder arguments to cp with the former.
来源:https://stackoverflow.com/questions/19820755/find-files-by-size-and-copy-them-to-other-directory