Вопрос

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