简体   繁体   中英

Copy large amout of files xargs

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 {} ';'

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 echo * | xargs cp -r --target-directory /directory/destination

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM