1

I was looking through the linux manual and on this page, the manual for find, specifically in the section about the test "-size", it states (erroneously) that a kilobyte is 1024 bytes. This is, as far as I learned, false. A kilobyte is 1000 bytes, and a kibibyte is 1024 bytes. So, what units does it actually use? Does it say "kilobytes" and mean "1000 bytes", or does it mean "1024 bytes" and incorrectly wrote "kilobytes"?

  • A kilobyte has traditionally been 1024 bytes; the revisionism to make "kilobyte" 1000 bytes is new. There is a great deal of opposition to this change in the industry. Look into the data sheet for any memory integrated circuit, or, heck, the Intel architecture manuals. – Kaz Feb 9 '18 at 0:00
  • 1
    I think that, given that the standard came out in 1999, has been around long enough to be obsoleted by a new more extensive International System of Quantities (itself 10 years old now), and had been on the table for a few years before that, we don't get to use the it's newfangled and I don't like new objection any more. That's really stretching the definition of "new". – JdeBP Feb 9 '18 at 5:48
  • Even if it's not technically correct, most people I know use kilobyte and friends in the 2^n definitions because kibi, mebi, etc. sound dumb. I have yet to find an occurrence where there's been confusion outside of hard drive sizes (and there, hard drive manufacturers don't get it right either!) – ErikF Feb 9 '18 at 7:27
1

Well spotted! The explicit explanation is correct. 1k means kibibytes (1024 bytes). I tested it by creating a range of sizes and seeing which were identified.

$ for i in 999 1000 1001 1023 1024 1025; do dd if=/dev/urandom of=$i bs=1 count=$i; done
$ find . -size 1k
.
./1024
./1023
./1001
./1000
./999

You can see that the 1024 bytes file is found (and not the 1025 bytes file).

(You might think of filing a bug report, if you like.)

  • The problem has been solved in several versions of find. – Isaac Feb 8 '18 at 23:38
  • It's not fixed in the latest stable version of findutils (4.6.0), which was released over two years ago. – Sparhawk Feb 9 '18 at 8:23
  • Distributions have not been using 4.6.0 for almost as long. Debian+Ubuntu have been using later versions since 2016, for examples, and both Debian 10 (in testing) and.Ubuntu 17.10.1 (released) already have the doco fix. – JdeBP Feb 9 '18 at 10:58
  • @JdeBP Oh right. I'm on Arch, which is using 4.6.0, and I normally presume that it's using versions that are no older then Debian/Ubuntu. Interesting that they've both shipped the unstable versions! – Sparhawk Feb 9 '18 at 11:45
3

The manual on the page you link is outdated and incorrect. One on line page where this error has been already corrected is:

-size n[cwbkMG]
File uses n units of space, rounding up. The following suffixes can be used:
`b' for 512-byte blocks (this is the default if no suffix is used)
`c' for bytes
`w' for two-byte words
`k' for Kibibytes (KiB, units of 1024 bytes)
`M' for Mebibytes (MiB, units of 1024 * 1024 = 1048576 bytes)
`G' for Gibibytes (GiB, units of 1024 * 1024 * 1024 = 1073741824 bytes)

The BSD find manual is still incorrect.

The most up-to-date manual is the man find in an updated OS.
From a GNU find version (find (GNU findutils) 4.7.0-git) the manual goes as:

-size n[cwbkMG]
File uses n units of space, rounding up. The following suffixes can be used:

`b' for 512-byte blocks (this is the default if no suffix is used)
`c' for bytes
`w' for two-byte words
`k' for Kibibytes (KiB, units of 1024 bytes)
`M' for Mebibytes (MiB, units of 1024 * 1024 = 1048576 bytes)
`G' for Gibibytes (GiB, units of 1024 * 1024 * 1024 = 1073741824 bytes)

So, the problem has been solved already in some versions of find.

  • There s no "error". The document defines what "kilobyte" means and the resulting description is consistent with the behavior of the software. (That definition happens to match the traditional one that was actually enshrined in IEEE POSIX documents at one point.) – Kaz Feb 9 '18 at 0:03
  • And, for that matter, why is it not an "error" in this revised page that the suffix "k" is used for "kibibytes"? Isn't that letter an S.I. unit prefix meaning 1000? – Kaz Feb 9 '18 at 0:07
  • 1
    As for my opinion: I learned long ago (in electronics) that a k meant 1024 bits. And that k meant 1000 in science (physics). I always found funny that the same prefix had two meanings. In present days, binary prefixes are being called i, so 1024 would be KiBytes. I find that an improvement and have gladly got used to accept it to avoid confusion. Exactly as the OP is being confused right now. – Isaac Feb 9 '18 at 0:21
  • 2
    The confusion is clear and persistent. A kilogram is one Kg and means only 1000 grams. A kilometer is 1000 meters. Only in some areas of human knowledge (mainly electronics) is common to see kilo used as 1024. It seems rational to me to use two names for two meanings: k for 1000 and ki for 1024. Yes, it will take some years for everyone to get there: have a happy journey @Kaz . – Isaac Feb 9 '18 at 0:33
  • 2
    @Kaz I have been in electronics for a long time, the dual use has been present for a long time. It always has been the custom to understand a kiloWatt as 1000 Watt. Nobody thinks of 1024 Watts. But it was custom to understand a kilobit as 1024 bits. Now that is being called a "binary kilobit" or a kibit. It seems reasonable to me. – Isaac Feb 9 '18 at 2:16

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.