linux - 如何比较两个目录的大小?

标签 linux bash command-line

我想比较不同文件系统上两个目录 dir1dir2 的总大小,这样如果 diff -r dir1 dir2返回 0 那么总大小将相等。 du 命令返回磁盘使用情况,其选项 --apparent-size 没有解决问题。我现在使用类似

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

知道 dir1 大小的近似值。有更好的解决方案吗?

编辑: 例如,我有(diff -r dir1 dir2 返回 0:它们相等):

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)

关于linux - 如何比较两个目录的大小?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3769206/

相关文章:

linux - linux Bash shell 如何检测扩展文件名(flv) (ass)

linux - 服务器命令行自动化(更新项目)

无需安装Xcode本身的xcodebuild命令工具

c - 在 docker 容器内运行时的不同结果

linux - 输出不正确 - 不明白为什么

bash - 并行运行 bash 命令,跟踪结果并计数

bash - 如何在 makefile 中获取向量的长度并在 for 循环中使用它?

c++ - 通过命令行编译C/C++/Visual C程序

linux - if 结构什么时候不需要括号?

python - 在 linux/sbin/ldconfig.real 上安装 opencv-python 时出错 :/usr/lib32/nvidia-384/libEGL. so.1 不是符号链接(symbolic link)