Directory Sizes

Alex alist at sprint.ca
Tue Apr 13 10:47:19 PDT 2004


There's something I don't understand about directory sizes, and I hope 
some kind soul can explain what for old Unix hands must appear as 
elementary.

I have a folder containing four files. Finder lists its content as 
follows:

    file_1    23 MB    (24,172,892)
    file_2   1.2 MB     (1,345,129)
    file_3   640 KB       (654,407)
    file_4   644 KB       (657,208)

    Total:  25.6 MB    (26,835,784)

(I added bytes in parantheses for obvious reasons.) Clearly, the sum of 
the sizes doesn't match the total, but, if I add the size of the 
invisible .DS_Store file, they do. So that's fine.

Now, I go to the Terminal. Here's what ls -al lists

       238  .
       272  ..
      6148  .DS_Store
  24172892  file_1
         0  file_2
         0  file_3
         0  file_4

(I draw the conclusion that ls doesn't know about resource forks, and, 
while file_1 is all data and no resource, the other three files have 
all their stuff in their resource forks.)

Then I do a du -k and the result is

   26216

which, multiplied by 1024 bytes, is 26,845,184. The sum of the sizes 
listed by ls is 24,179,550, so I assume that, unlike ls, du knows about 
resource forks. Nevertheless, there is a discrepancy between the total 
reported by Finder and the total reported by du. Why? (And, an 
ancillary question: Is there a command which does what ls does, but 
knows about resource forks?).

TIA, f




More information about the X-Unix mailing list