比较两个目录中的文件并写入增量
问题描述:
我无法找到两个目录之间的区别:什么更新了,什么删除了。 之后,我需要将新文件保存到存档和已删除文件的列表中。比较两个目录中的文件并写入增量
之后,我需要与第一个目录+增量拷贝到新目录中并重新创建有目录2.
这一切都必须要快=)
我试着rsync的
time rsync -rv --dry-run --delete ./10 ./130
sent 775081 bytes received 105052 bytes 352053.20 bytes/sec
total size is 838724381 speedup is 952.95 (DRY RUN)
real 0m1.270s
user 0m0.300s
sys 0m0.484s
但我没有看到删除的文件
rsync --version
rsync版本3.0.9协议版本30 Andrew Tridgell,Wayne Davison和其他人的版权(C)1996-2011。 网站:http://rsync.samba.org/
也许我不明白成才:
[email protected]:/home.local/diff# rm -rf a/
[email protected]:/home.local/diff# rm -rf b
[email protected]:/home.local/diff# mkdir a b
[email protected]:/home.local/diff# touch b/ssdf
[email protected]:/home.local/diff# touch a/c
[email protected]:/home.local/diff# rsync --dry-run -i --delete-delay --stats -a a b |grep "deleting"
[email protected]:/home.local/diff# rsync --dry-run -i --delete-delay --stats -a a b
cd+++++++++ a/
>f+++++++++ a/c
Number of files: 2
Number of files transferred: 1
我在不存在其他目录中的文件创建,但他们不会删除?
答
rsync
未必会更快。您正在观察的是Linux文件系统缓存:
$ time find /usr/share > /dev/null
real 0m6.779s
user 0m0.082s
sys 0m0.199s
$ time find /usr/share > /dev/null
real 0m0.109s
user 0m0.043s
sys 0m0.064s
请注意第二次搜索是如何进行的。
不能运行之前:rsync的--dry运行-i --delete延迟--stats -a ./131 ./230 真正0m1.487s 用户0m0.304s时间 SYS 0m0.568s – 2014-09-04 14:44:13
@ ValeriySolovyov尝试格式化您的评论,使其可读。 – 2014-09-04 14:45:24
我测试rsync和diff。 Rsync速度更快,但并不重要。我没有找到答案。 – 2014-09-07 06:40:29