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
to know an approximation of dir1's size. Is there a better solution?
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