Your
find command is matching on both files and directories. When it encounters a directory, it passes that name to
cp, which replicates that subtree,
including both new and old files, in the target directory, /share/_docs2. But then,
find itself recurses into that directory, finds any new files (and subdirectories again!), and passes those names to
cp, which will copy them directly into /share/_docs2. If in _docs you have this:
Code:
dir1/
file1
subdir1a/
file1a
and all of the files and directories satisfy the "-newer" test, the command line produced by
xargs will be:
Code:
cp -Rp -t /share/_docs2 \
/share/_docs/dir1 /share/_docs/dir1/file1 /share/_docs/dir1/subdir1a /share/_docs/subdir1a/file1a
and your result in /share/_docs2 will be this:
Code:
dir1/
file1
subdir1a/
file1a
file1
subdir1a/
file1a
file1a
The whole tree gets replicated in the target, but every element of that tree gets copied
again directly to the target directory, regardless of its original place in the tree. Any duplicate names will cause a conflict, but that is really secondary to the whole operation being fundamentally flawed.
A quick solution to this eludes me at the moment. Anyone???