GNU `find` 似乎无法使用 -size 来查找大小小于 *M 的文件
GNU `find` seems not work with -size to find the file whose size is less than *M
我要查找小于1M的文件,所以写成find . -size -1M
。但它似乎确实不起作用:
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
相反,find . -size 1M
的效果令人惊奇。
来自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.
我要查找小于1M的文件,所以写成find . -size -1M
。但它似乎确实不起作用:
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
相反,find . -size 1M
的效果令人惊奇。
来自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.