Reputation: 1689
I'm trying to copy large amount of file from one directory to another using xargs command. But this one does not seems to work right.
# echo * |xargs cp -r /directry/destination
what I am doing wrong?
Here is what it returns:
cp: target `file name' is not a directory
Upvotes: 0
Views: 338
Reputation: 1
find -maxdepth 1 -mindepth 1 -exec cp -r -t /directry/destination {} ';'
Upvotes: 1
Reputation: 11366
by default cp interprets the LAST argument as the target directory when there is more than one source directlry, but the way you have it, you have cp -r target source1 source2 source3...
. So it is going to think you intend to copy things to the last source instead of the target. If you are using gnu coreutils, you should have a -t
or --target-directory
switch so you can specify which directory you intend to use as the destination, so you could use echo * | xargs cp -r --target-directory /directory/destination
Upvotes: 0