find does not handle -size parameter 1 correctly

Bug #659771 reported by mrvanes
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
findutils (Debian)
Confirmed
Unknown
findutils (Ubuntu)
Opinion
Undecided
Unassigned

Bug Description

Binary package hint: findutils

When I use find, to find file smaller dan 1024 bytes like this
$ find -size -1024c

the example result is:
./Briefcase/Test/pasfoto.jpg.meta
./Briefcase/cimg0087.jpg.meta
./Briefcase.meta

However, when switching to the k multiplier I don't get any result until I use 2, instead of 1:
$ find -size -1k
$ find -size -2k
./Briefcase/Test/pasfoto.jpg.meta
./Briefcase/cimg0087.jpg.meta
./Briefcase.meta

The same is true for M and G; It seems there's a bug in handling 1's in the -size parameter.

ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: findutils 4.4.2-1ubuntu1
Uname: Linux 2.6.35 x86_64
Architecture: amd64
Date: Wed Oct 13 10:44:57 2010
ProcEnviron:
 LANGUAGE=
 LANG=en_US.UTF-8
 SHELL=/bin/bash
SourcePackage: findutils

Revision history for this message
mrvanes (mrvanes) wrote :
Revision history for this message
Andreas Metzler (k-launchpad-downhill-at-eu-org) wrote :

This is not a bug.

Quoting the documentation:

------------------
-size n[bckwMG]
     True if the file uses N units of space, rounding up.
[...]
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.
------------------

Therefore -size -1k matches all empty files. Any nonempty files uses at least 1KB ("units of space,") if you you round up.

Revision history for this message
Stefan Wagner (wagner-stefan) wrote :

I consider this a bug, too.

The reason to not threat it as a bug might be, that you don't want a file to match -1M and +1M if it is exactly 1M, but how often do you have a file of exactly 1M? If you did a dd-command with testdata, or a split perhaps.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in findutils (Ubuntu):
status: New → Confirmed
Changed in findutils (Debian):
status: Unknown → Confirmed
Revision history for this message
Stefan Wagner (wagner-stefan) wrote :

OK - After a second thought, I come to the conclusion that it might be better to keep it the way it is.

Sometimes you search for files bigger than x, sometimes smaller than x and rarely exactly x, but maybe sometimes for small sizes for exactly X rounded to current measurement (4G, 4M, 4K for example).

Searching for up to 4k with -size 4k seams reasonable. Only for the size -1k it seams redundant to -empty and maybe unexpected. To have an uniform behaviour for -3k, -2k, -1k seems to be the right or at least a reasonable way.

Revision history for this message
Stefan Wagner (wagner-stefan) wrote :

OK - After a second thought, I come to the conclusion that it might be better to keep it the way it is. See #5 https://bugs.launchpad.net/ubuntu/+source/findutils/+bug/659771/comments/5

Changed in findutils (Ubuntu):
status: Confirmed → Opinion
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.