bash - Rsync在传输前计算文件数?
问题描述
当使用 rsync 在许多文件夹中传输大量小文件时,它往往会停留ir-chk=1000/xxxxx
在 xxxxx 发现新文件时不断计数,并且要检查的数量保持在 1000 左右,直到最后几个文件夹。
我怎样才能让它在复制之前检查整个文件数?
我用来复制的命令是:
rsync -av --progress source dest
解决方案
rsync -av --progress --dry-run --stats source dest
- 选项
--dry-run
不传输任何文件,但会显示将传输多少字节。 - 选项
--stats
显示摘要。
示例输出:
...
tests/
tests/__init__.py
tests/test_config.py
Number of files: 5,033 (reg: 2,798, dir: 2,086, link: 149)
Number of created files: 5,032 (reg: 2,798, dir: 2,085, link: 149)
Number of deleted files: 0
Number of regular files transferred: 2,798
Total file size: 26,035,530 bytes
Total transferred file size: 26,032,322 bytes
Literal data: 0 bytes
Matched data: 0 bytes
File list size: 0
File list generation time: 0.004 seconds
File list transfer time: 0.000 seconds
Total bytes sent: 158,821
Total bytes received: 17,284
sent 158,821 bytes received 17,284 bytes 117,403.33 bytes/sec
total size is 26,035,530 speedup is 147.84 (DRY RUN)
获取将要传输的文件数
rsync -av --progress --dry-run --stats source dest |
fgrep 'Number of files' |
cut -d' ' -f4 |
tr -d ,
推荐阅读
- r - 由于路径中的重音,在 R 中使用 readJPEG 打开 .jpg 时出错
- c++ - 从 QUdpSocket 发送的数据包在 Wireshark 中看不到
- c++ - Travis CI 从源日志限制错误安装提升
- php - 如何使用 WP REST API 随机排序帖子?
- sql - 从多个表格中选择特定单元格
- java - 如何使 GUI 上的多个按钮工作
- docker - Docker 镜像运行不正确的命令
- python - 使用快捷方式打开 tkinter 窗口
- microsoft-graph-api - 使用 Graph API 发送慢速 Outlook 电子邮件
- python - 使用 hough_line 后关于 hough_line_peaks 的说明