Some problems with this script:
- You sum file sizes. But file size is the number of
bytes in a file, while disk usage of a file is counted
in blocks (block size depends on the file system).
4 files each containing 1 character take 4 blocks
(plus 4 inodes), while 1 file containing 4 characters
takes just one block.
- Directories take disk space as well - you don't count them.
The amount of space they use depend on the number of files
and the length of the file names in that directory.
- Creating a 10 Mb file, and then making another link to
it only takes an extra directory entry, but your script would
count it as 20 Mb.
I'd strongly urge you to use
du or another specialized
tool. Because it's specialized, it will be faster, and generate
more useful data.
Abigail