As long as I've been living in *nix world I've lived under the assumption that when a command accepted a
-h flag the only thing I was changing was effectively formatting of a print statement. I don't usually re-examine this, but have definitely found this to be the case in general.
Today I had a very strange experience when measuring the size of a directory that I was actively writing to.
>>> du -s 15565160 . >>> du -sh 7.4G .
At first I thought that I was just catching the directory in a strange place, but I found that both values were quite persistent, returning only slightly increased/decreased values as I kept writing to the directory. My first assumption was that it was some strange intermediary state, but in that case I would have expected wild swings in the result of
du -s that I did not observe.
What's going on here? What is the
155... number? It doesn't seem like it's bytes. There seems to be a pretty consistent ratio between the two of about 450. That is, if I multiple the result of
du -s by 450 I get pretty close to the number of bytes implied by
The bigger question is if I've been wrong all along. Why is adding the
-h flag in this context doing anything other than changing the print format?