我注意到列出5 GiB以下文件的这两个命令会产生不同的结果:
find . -type f -size -5368709120c
find . -type f -size -5G
特别是使用千字节单位的那个( 5368709120c
)返回大于使用GiB单元的文件返回的最大文件大小的其他文件( 5G
)。
来自 find
手册页我读了以下内容:
-size n[cwbkMG]
File uses n units of space. The following suffixes can be used:
`b' for 512-byte blocks (this is the default if no suffix is used)
`c' for bytes
`w' for two-byte words
`k' for Kilobytes (units of 1024 bytes)
`M' for Megabytes (units of 1048576 bytes)
`G' for Gigabytes (units of 1073741824 bytes)
The size does not count indirect blocks, but it does count blocks
in sparse files that are not actually allocated. Bear in mind that the `%k'
and `%b' format specifiers of -printf handle sparse files differently. The
`b' suffix always denotes 512-byte blocks and never 1 Kilobyte blocks,
which is different to the behaviour of -ls.
所以,鉴于该单位 G
是1073741824, 5G
应该 5368709120c
。该问题是由于计算稀疏或间接块的原因吗?
在此先感谢您的帮助。