6

In Centos, I have a text file in my home directory.

The command find . -size -1M doesn't show my file but find . -size -1000k does show it. This problem just seems to be happening when I use the number "1". The first command will work if I use -2M even though the file is only 500k in size.

Am I doing something wrong?

  • 3
    1M == 1024k, not 1000k – daisy Oct 13 '12 at 12:14
  • Cheers, rookie mistake. – Lukas88 Oct 13 '12 at 22:27
6

find . -size -1M will only show file of size less than 1M, that is 0M. Yes, I know, it's confusing.

find . -size 1M will show you files whose size (rounded up to the upper MiB) is 1M (so any file size from 1 to 1048576). If you want from 0 to 1048575 (< 1M), that would be:

find . -size -1048576c

If you want from 0 to 1048576 (<= 1M)

find . -size -2M

or

find . ! -size +1M

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.