如何比较两个目录的大小? [英] How to compare the size of two directories?

查看:94
本文介绍了如何比较两个目录的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想比较不同文件系统上的两个目录 dir1 dir2 的总大小, diff -r dir1 dir2 返回 0 ,则总大小将相等。 du 命令返回磁盘使用情况,其选项 - apparent-size 无法解决问题。我现在使用像

I want to compare the total size of two directories dir1 and dir2 on different file-systems so that if diff -r dir1 dir2 returns 0 then the total sizes will be equal. The du command returns the disk usage, and its option --apparent-size doesn't solve the problem. I now use something like

find dir1 ! -type d |xargs wc -c |tail -1

以了解dir1大小的近似值。是否有更好的解决方案?

to know an approximation of dir1's size. Is there a better solution?

编辑:
例如,我有( diff -r dir1 dir2 return 0:they are equal):

edit: for example, I have (diff -r dir1 dir2 returns 0: they are equal):

du -s dir1 --> 540
du -s dir2 --> 166

du -sb dir1 --> 250815 (the -b option is equivalent to --apparent-size -B1)
du -sb dir2 --> 71495

find dir1 ! -type d |xargs wc -c --> 62399
find dir2 ! -type d |xargs wc -c --> 62399 


推荐答案

我不知道你想要什么。也许你想要这个?

diff<(du -sh dir1)<(du -sh dir2)

i can't know what you want clearly. Maybe you want this?
diff <(du -sh dir1) <(du -sh dir2)

这篇关于如何比较两个目录的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆