'GNU `find` seems not work with -size to find the file whose size is less than *M
I want to find the file whose size is less than 1M, so I write as find . -size -1M. But it seems not work indeed:
find . -size -1M | xargs ls -lh
-rw-rw-r-- 1 xyz xyz 0 Apr 2 14:48 ./test/score
-rw-rw-r-- 1 xyz xyz 0 Apr 2 14:48 ./test/ir1
On the contrary, it's amazing that find . -size 1M works.
Solution 1:[1]
From man find:
The + and - prefixes signify greater than and less than, as usual; 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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Nic3500 |
