I have a folder and it is 16.91GB in size(I checked in Finder).

I tried to check the size by using du command.

So, I tried du -sh ~/folder and I got 16G.

I thought I will get the output in Bytes and convert it. But I don't understand the metric when -h is not given.

du -s ~/folder

Gives 33041320. I thought it is in bytes but I'm wrong. In which format it is in?

How can I get 16.91GB instead of 16G?

Note: I believe the behaviour is same in linux also, so I tagged linux. If it's wrong, let me know or remove the tag please.

Thank you.

1 Answer 1

  1. In which format is 33041320 ?
    33041320 is the number of 512-byte blocks. From man page:

    If the environment variable BLOCKSIZE is set, and the -k option is not specified, the block counts will be displayed in units of that size block. 
    If BLOCKSIZE is not set, and the -k option is not specified, the block counts will be displayed in 512-byte blocks.   
  2. how do I get 16.91 instead of 16?
    seems that you cannot. The reason why finder reports 16.91 is that finder treats 1000 bytes as 1k. so technically speaking, the figure reported by finder is incorrect. 33041320*512/1000/1000/1000=16.91

  • So if I do 33041320 * 512 I get 16917155840 bytes( Am I correct?). Which is 15.755GB. I'm getting 1.16GB less. Is there any command from which I can get exact value of 16.91GB? Mar 14, 2017 at 8:44
  • @SkrewEverything Technically speaking, 16.91 is incorrect. reason is that finder treats 1000 bytes as 1k (starting from Snow Leopard). 33041320*512/1000/1000/1000=16.91 Mar 14, 2017 at 8:50
  • du --si gives you the size in linux. If you are wanting to calculate it above, use 33041320 * 500 (because 500 * 2 = 1000, while 512 * 2 = 1024)
    – davidgo
    Mar 14, 2017 at 8:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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