*nix quickie - du command - how to compare *nix/Windows directory sizes
Posted on 2007-09-28
I uploaded a set of files to my Linux server via FTP, from my Win2K machine.
If I look at the file properties of the parent directory (call it 'Files') under Windows, I get the following info:
Size: 12,147,595 bytes
Contains: 3,099 files, 277 folders.
After running the upload (which was unattended) I wanted to check that everything was present and correct, so I ran the following command from the remote 'Files' directory to see the total number of files:
$ find . -type f | wc -l
As you can see, the file count was correct. I then ran the following command (again, from the 'Files' directory) to get the total size of the uploaded files:
$ du -b | tail -n1
This size is different to the size reported by Windows. I expect part of this is due to the fact that directory entries count as 1024 bytes, but even removing 1024 * 277 folders (283,648) I get a total of 12,183,324 - still more than the expected 12,147,595 reported by Windows.
So therefore, 2 questions:
1) Why is the total file size reported by these two methods different.
2) What is the correct *nix command that I should use to get the actual file size of the files only (i.e. the size reported by Windows).
 Slackware 11.0.0, Linux version 220.127.116.11