I can't figure out why I'm getting the following results:
ls -l tells me the size of a given file (HISTORY) is "581944":
$ ls -l HISTORY -rw-rw-r-- 1 waldyrious waldyrious 581944 Feb 22 10:59 HISTORY
ls -s says it is "572":
$ ls -s HISTORY 572 HISTORY
I obviously need to make the values use a comparable scale. So first I confirm that using
--block-size 1 in
ls -l gives me the same result as before:
$ ls -l --block-size 1 HISTORY -rw-rw-r-- 1 waldyrious waldyrious 581944 Feb 22 10:59 HISTORY
Then I do the same to
ls -s to get a value in the same scale:
$ ls -s --block-size 1 HISTORY 585728 HISTORY
Different results! 581944 ≠ 585728.
I tried generating comparable values the other way around, using
-k, but I get:
$ ls -lk HISTORY -rw-rw-r-- 1 waldyrious waldyrious 569 Feb 22 10:59 HISTORY $ ls -sk HISTORY 572 HISTORY
Again, different results, 569 ≠ 572.
I tried specifying --si to make sure both options were using the same scale, to no avail:
$ ls -lk --si HISTORY -rw-rw-r-- 1 waldyrious waldyrious 582k Feb 22 10:59 HISTORY $ ls -sk --si HISTORY 586k HISTORY
...again, different values: 582k ≠ 586k.
I tried searching the web but the only thing I could find that seemed relevant was this:
Some files have "holes" in them, so that the usage listed by
ls -s(...) is less than the file size listed by
(note that in my results the opposite happens:
ls -s returns sizes bigger than
ls -l, not smaller.)
Meanwhile, this page says that
there is no elegant way to detect Unix file holes.
So, how can I deal with this discrepancy? Which of these values can be considered correct? Could this possibly be a bug in