You are not logged in.

#1 2026-03-06 17:16:14

Succulent of your garden
Member
From: Majestic kingdom of pot plants
Registered: 2024-02-29
Posts: 1,424

question about find -size

So I'm having like doubt with how find by default defines the sizes, like by using medi,gibi or like mega,giga bytes, or even both.

Let me explain, let's suppose I have this command:

sudo find / -type f -name "*" -size +1022M

That will search all files that are more bloated than 1022M. but that 1022M is medibytes or megabytes ?
I do have now the confusion now, from example for this link:

https://unix.stackexchange.com/question … their-size

website wrote:

Note that the M in find . -size +10M, is a GNU extension. The GNU implementation of find has another extension: -printf that you can use to print the size of those files

I went into the gnu and found this: https://www.gnu.org/software/findutils/ … .html#Size

gnuWebSite wrote:

The ‘b’ suffix always considers blocks to be 512 bytes. This is not affected by the setting (or non-setting) of the POSIXLY_CORRECT environment variable. This behaviour is different from the behaviour of the ‘-ls’ action). If you want to use 1024-byte units, use the ‘k’ suffix instead.

The number can be prefixed with a ‘+’ or a ‘-’. A plus sign indicates that the test should succeed if the file uses at least n units of storage (a common use of this test) and a minus sign indicates that the test should succeed if the file uses less than n units of storage; i.e., an exact size of n units does not match. Bear in mind that the size is rounded up to the next unit. Therefore ‘-size -1M’ is not equivalent to ‘-size -1048576c’. The former only matches empty files, the latter matches files from 0 to 1,048,575 bytes. There is no ‘=’ prefix, because that’s the default anyway.

The size is simply the st_size member of the struct stat populated by the lstat (or stat) system call, rounded up as shown above. In other words, it’s consistent with the result you get for ‘ls -l’. This handling of sparse files differs from the output of the ‘%k’ and ‘%b’ format specifiers for the ‘-printf’ predicate.

But it didn't help me in that, so went into wikipedia and found this:
https://en.wikipedia.org/wiki/Gibibyte# … byte_units

You can see in the table that are binary Kilo,mega, and so on , and a decimal one version, which seems to be like heritage and sometimes used by companies.

But my question is how the hell find uses under the hood ? It treats both system and binary and in the end are equal ? or one by decimal and the other by binary.

Is find like making the --size 1022M == 1022MediBytes == 1022MegaBytes because both are treated in binary based system ? I'm really confused, minor first world existential crisis is now with me. Because also find have the -c flag to declare in bytes, but imagine declaring one zetaByte with that flag lol.

This doesn't have sudo usage, but I think it belongs here, i guess.

Last edited by Succulent of your garden (2026-03-06 17:16:51)


str( @soyg ) == str( @potplant ) btw!

Also now with avatar logo included!

Offline

#2 2026-03-06 19:14:16

seth
Member
From: Don't DM me only for attention
Registered: 2012-09-03
Posts: 73,878

Re: question about find -size

but that 1022M is medibytes or megabytes ?

"Mebibytes" ie. 2^10, not 10^3 arithmetics
https://man.archlinux.org/man/find.1#size

1022M is 1024*1022k is 1024^2*1022 bytes
Pay attention to the note about rounding

Offline

Board footer

Powered by FluxBB