Next: , Previous: Time, Up: Finding Files


2.4 Size

— Test: -size n[bckwMG]

True if the file uses n units of space, rounding up. The units are 512-byte blocks by default, but they can be changed by adding a one-character suffix to n:

b
512-byte blocks (never 1024)
c
bytes
k
kilobytes (1024 bytes)
w
2-byte words
M
Megabytes (units of 1048576 bytes)
G
Gigabytes (units of 1073741824 bytes)

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. There is no `=' prefix, because that's the default anyway.

The size does not count indirect blocks, but it does count blocks in sparse files that are not actually allocated. In other words, it's consistent with the result you get for ‘ls -l’ or ‘wc -c’. This handling of sparse files differs from the output of the ‘%k’ and ‘%b’ format specifiers for the ‘-printf’ predicate.

— Test: -empty

True if the file is empty and is either a regular file or a directory. This might help determine good candidates for deletion. This test is useful with ‘-depth’ (see Directories) and ‘-delete’ (see Single File).