I need to get the size of directory in terminal for signing purposes. I'm using following command:du -s /path/to/dirI'm multiplying the result by traditional UNIX block size (512 bytes) and get actual directory size in bytes. However, the Finder's Get Info dialog window shows the size slightly smaller than the one calculated with the terminal command. And it seems that it's reproducible on any folder/bundle. What am I missing?
Directory size calculation difference
osx;disk usage
Normally, du shows information about disk usage (which is where its name comes from). Keep in mind thatdisk usage != sum of file sizesBecause each file takes up a number of blocks on the filesystem (see man mkfs.ext2 for example). This means that only in a very rare situation a disk usage of a file equals its actual size - for that, the size must be exactly a multiple of the block size.Think of filesystem blocks as boxes that contain parts of files - each can contain a part of only one file.For GNU version of du, check out the --apparent-size option.An even more interesting situation can take place, when there are some sparse files on the file system!