Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have written a small backup script with rsync. I would like to monitor its progress by comparing the total file sizes on the source and destination directories. du Is inaccurate because it measures the disk usage, not the file size, and the disk usage varies between file systems.

How can I summarize the file sizes of an entire directory structure?

share|improve this question
up vote 6 down vote accepted

Perhaps the --apparent-size option for du will do what you are after:

       print apparent sizes,  rather  than  disk  usage;  although  the
       apparent  size is usually smaller, it may be larger due to holes
       in (`sparse') files, internal  fragmentation,  indirect  blocks,
       and the like

That should remove the dependence on file system block sizes or other metadata.

share|improve this answer
It's way better, but the result still differs a little bit - do you have an educated guess why? – Adam Matan Aug 17 '11 at 11:17
Perhaps the directories themselves (as opposed to the files stored in the directories) report different sizes on the two file systems? – James Henstridge Aug 18 '11 at 9:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.