toybox
toybox copied to clipboard
find -size <number-without-suffix> not POSIX
Per POSIX
find . -size n
is meant to return the files whose size rounded up to an integer number of 512-byte units is 1.
For instance, find . -size 1
is meant to report the files whose size ranges from 1 to 512 bytes (the ones that would typically occupy one sector of disk space in the olden days).
But for toybox (and busybox, which shares the same non-conformance), it only reports files whose size is exactly 512.
There are similar problems for find . -size +n
and find . -size -n
.
Like for the test
utility (https://github.com/landley/toybox/issues/498), there's also the separate problem that find . -size 010c
finds the files of size 8 instead of 10.
Note the behaviour when using suffixes other than c
is fine as out of the POSIX scope and is aligned with most other implementations that support those or some of those suffixes (except GNU find
).
See https://unix.stackexchange.com/questions/774817/what-are-the-file-size-options-for-find-size-command/774840#774840 for more of the gory details including comparison with other implementations.