有没有最快的选项将文件从 dir1 复制到 dir2?

发布于 2024-10-06 08:20:26 字数 296 浏览 0 评论 0原文

我使用 cp 在 Linux 盒子中复制大量小文件(b/n 1M 和 10M 大小;总共约 6G)。没有计时,但由于我要一次又一次cp,可以计时吗,稍后再具体一点;但由于 cp 不是主要任务,如果有更好的选择/选择/方式,就无法忍受它所花费的时间。因此,如果有更好的方式/选项/方法将文件从一个目录cp-ing(更快)到另一个目录,请很高兴尝试一下。

谢谢,

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,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

盛夏尉蓝 2024-10-13 08:20:26

tar/untar 或 rsync 当被告知不要校验和时会更快,因为它们批量读取文件而不是逐一处理它们。

Either of tar/untar or rsync when told not to checksum will be faster, since they bulk-read files instead of handling them one-by-one.

路弥 2024-10-13 08:20:26

您可以尝试 cpio,因为它有一个复制目录到目录模式。

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

萤火眠眠 2024-10-13 08:20:26

使用 perl 进行最快的复制:

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

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!
一萌ing 2024-10-13 08:20:26

尝试仅备份今天的文件:

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

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

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/

一个人的夜不怕黑 2024-10-13 08:20:26

您尝试过吗:(

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

来源:https://lists.debian.org/ debian-user/2001/06/msg00288.html)

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)

北座城市 2024-10-13 08:20:26

你可以使用焦油。这是我发现的最快的方法。

cd /path/to/SOURCE_FOLDER; tar cf - . | (cd /path/to/DESTINATION_FOLDER; tar xvf -)

此命令将 SOURCE_FOLDER 的内容压缩到 tar 存档中,然后将该存档提取到 DESTINATION_FOLDER 中,同时保留目录结构。

You could use tar. It's the fastest way I found.

cd /path/to/SOURCE_FOLDER; tar cf - . | (cd /path/to/DESTINATION_FOLDER; tar xvf -)

This command compresses the contents of SOURCE_FOLDER into a tar archive and then extracts that archive into DESTINATION_FOLDER, preserving the directory structure.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文