bugfindutils - Bugs: bug #36539, -size flag seems to be broken

 
 

bug #36539: -size flag seems to be broken

Submitter:  None
Submitted:  Fri 25 May 2012 06:34:57 PM UTC
   
 
Category:  find Severity:  3 - Normal
Item Group:  Wrong result Status:  Duplicate
Privacy:  Public Assigned to:  None
Originator Name:  Patrick O'Neill Originator Email:  -email is unavailable-
Open/Closed:  Closed Release:  4.4.2
Fixed Release:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Sun 27 May 2012 09:54:35 PM UTC, comment #2: 

Sorry for the duplication-- I registered my two cents on the original thread.  FWIW, I think that adding another flag that implements the intuitive behavior has a lot of appeal in addition to the obvious advantage that it has already been suggested by the project's maintainer.

Patrick O'Neill <poneill>
Fri 25 May 2012 08:04:37 PM UTC, comment #1: 

This is a duplicate of bug 12162.  The issue is that the current syntax is interpreted as 'treat the suffix of the -size argument as block size, then round the files up to that block size, then filter based on larger or smaller than the boundary'.  Thus, -size -50k says to find files less than 50 (1024) when rounded to 1024 blocks, while -size -1M says to find files less than 1 (1024*1024) when rounded to (1024*1024) blocks.  50k rounds up to 1M, so it is not less than 1 block of size 1M per block.

This is not intuitive, but changing it might break existing syntax.  Suggestions on how to proceed are welcome.

Eric Blake <ericb>
Group administrator
Fri 25 May 2012 06:34:57 PM UTC, original submission:  

The -size flag for GNU find behaves strangely. Let's say I have the following three files in a directory:

$ lh
total 8.7M
-rw------- 1 wvoq wvoq  42K 2012-05-24 18:25 small
-rw------- 1 wvoq wvoq 7.3K 2012-05-24 18:37 tiny
-rw------- 1 wvoq wvoq 8.7M 2012-05-24 18:37 big

Two of the files are less than 1MB, and the other is about 9MB. Which of the files are less than 50K in size?

$ find -type f -size -50k
small
tiny

Which is what we expect. But which are less than 1MB in size?

$ find -type f -size -1M
$

Necessarily, any file less than 50k is also less than 1M, so why the discrepancy? Even more disturbingly, we have:

$ find -type f -size -2M
small
tiny

which would seem to suggest that small and tiny are between 1 and 2 MB in size, when in fact they are both <50k.

(cf. http://stackoverflow.com/questions/10759111/is-the-gnu-find-size-flag-broken)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by poneill (Posted a comment)
  • -email is unavailable- added by ericb (Posted a comment)
  • -email is unavailable- added by None (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2012-05-25 ericb StatusNone Duplicate
        Open/ClosedOpen Closed

    Back to the top

    Powered by Savane 3.13-4448.
    Corresponding source code