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
有帮助吗?

解决方案

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

Example

其他提示

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top