Question

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
Was it helpful?

Solution

find -maxdepth 1 -mindepth 1 -exec cp -r -t /directry/destination {} ';'

Example

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top