简体   繁体   中英

is there a fastest option to cp files from dir1 to dir2?

i used cp to copy lots of small files (b/n 1M and 10M size; around 6G total) in Linux box. Didn't time it but since i am going to do cp again and again, can time it and be more specific later; but since the cp is not the major task, can't tolerate the time it's taking if there is a better option/choice/way. So, if there is a better way/option/method to do cp -ing (faster) files from one dir to another, be glad glad to try it out.

Thanks,

告诉tar / untar或rsync任何一个,当它们不进行校验和检查时,都会更快,因为它们会批量读取文件,而不是一一对应地处理它们。

Have you tried:

time (cd /usr/local/src/ && tar pcf - cvs.gnome.org) | buffer -m 8m -p 75 | (cd /mnt/tmp/src/ && tar pxf -) 

(Credits: https://lists.debian.org/debian-user/2001/06/msg00288.html )

You could try cpio , as that has a copy directory to directory mode.

use perl for fastest copy:

use File::Copy::syscopy;  # preserves OS specific file attributes
copy($foo,$bar) or die "cannot copy $foo to $bar: $!";  # always check for errors!

Try this just backup today's files:

find /home/me/files -ctime 0 -print -exec cp {} /mnt/backup/{} \;

from: http://commandperls.com/find-all-today%E2%80%99s-files-and-copy-them-to-another-directory/

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