find /etc -size -1G return only empty files

Chris Adams cmadams at hiwaay.net
Thu Mar 25 18:57:30 UTC 2010


Once upon a time, Rick Stevens <ricks at nerd.com> said:
> I have to disagree that's the documented behavior either in the info or
> man pages, and while find's own "--help" output is poorly laid out, it
> also makes no mention of block sizes.

The man page size "File uses n units of space"; the suffixes change the
units, but it is still an integer (rounded-up) value.  If you read the
Single Unix Specification spec for find, it makes it clear that the
-size option is rounded up to the blocksize (although suffixes other
than "c" are not in the standard).

The info page says this better:

   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:

You are always specifying a unit size, and "-1" (less than 1) of any
unit can only be 0.

-- 
Chris Adams <cmadams at hiwaay.net>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.


More information about the users mailing list