Bug 246122 - find -size does not work properly with 'M' unit
Summary: find -size does not work properly with 'M' unit
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: findutils   
(Show other bugs)
Version: 5.0
Hardware: All
OS: Linux
Target Milestone: ---
: ---
Assignee: Vitezslav Crhonek
QA Contact:
Depends On:
TreeView+ depends on / blocked
Reported: 2007-06-28 17:29 UTC by ladislav
Modified: 2007-11-30 22:07 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-09-25 14:15:11 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

Description ladislav 2007-06-28 17:29:38 UTC
Description of problem:

find -size [<mod>]<x>M does work

Version-Release number of selected component (if applicable):


How reproducible:

compare file sizes

Steps to Reproduce:
1. dd if=/bin/false of=onemeg bs=1024 count=1024
   dd if=/bin/false of=onemegplus bs=1024 count=1025
   dd if=/bin/false of=onemegminus bs=1024 count=1023

2. find -size 1M;find -size -1M;find -size +1M
Actual results:

foof@e31 m70]$ find -size 1M
[foof@e31 m70]$ find -size -1M
[foof@e31 m70]$ find -size +1M

Expected results:

[foof@e31 m70]$ find -size 1M
[foof@e31 m70]$ find -size -1M
[foof@e31 m70]$ find -size +1M

Additional info:

Comment 1 Vitezslav Crhonek 2007-09-25 14:15:11 UTC
This behaviour is correct, see the documentation:


"True if the file uses n units of space, rounding up.". _Rounding up_! In the
package man page (including lates version) this sentence is a bit different
"File uses n units of space.". Try report bug to upstream.

With 1M, onemegminus is round to 1M, that's the reason, why find -size 1M both
files are returned. If you try your example with find {+,-, }1024k, you get what
you expect.
Maybe this will help you understand:

[vcrhonek@norcus tmp]$ ls -alh
total 29M
drwxr-xr-x  2 vcrhonek vcrhonek 4.0K Sep 25 15:47 .
drwx------ 82 vcrhonek vcrhonek 4.0K Sep 25 14:23 ..
-rw-rw-r--  1 vcrhonek vcrhonek 5.0M Sep 25 15:41 fivemeg
-rw-rw-r--  1 vcrhonek vcrhonek 4.0M Sep 25 15:45 fourmeg
-rw-rw-r--  1 vcrhonek vcrhonek 7.0M Sep 25 15:44 sevenmeg
-rw-rw-r--  1 vcrhonek vcrhonek 6.0M Sep 25 15:44 sixmeg
-rw-rw-r--  1 vcrhonek vcrhonek 3.5M Sep 25 15:47 threeandhalf
-rw-rw-r--  1 vcrhonek vcrhonek 3.0M Sep 25 15:44 threemeg
[vcrhonek@norcus tmp]$ find -size 5M
[vcrhonek@norcus tmp]$ find -size 4M
[vcrhonek@norcus tmp]$ find -size -4M

Comment 2 ladislav 2007-09-25 16:36:34 UTC
Thanks for pointing out the rounding up.

Very counter intuitive and twisted imnsho, but as you point out, correct
behavior per the man page.  (Compare with same in k units for example.)

Note You need to log in before you can comment on or make changes to this bug.