The -size -nnnnnX check works like this:

How many units sized one X each is the file using, 
a) less than nnnnn
b) at least nnnnn

Therefore -size -1M or -size -1k or -size -1c all match only empty

A 1025 byte sized file uses two 1K-units (it has to, there is only space
for 1024 bytes in a single 1K unit) and will therefore not match -size

cu Andreas

** Changed in: findutils (Ubuntu)
       Status: New => Invalid

You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to findutils in Ubuntu.

  find -size -Nk seems to be off by 1

Status in findutils package in Ubuntu:

Bug description:
  If I have a file of size less than 1k, and use:
      find -size -1k
  to try to find it, it doesn't.
  If I use
       find -size -1000c
  it does find it.  If I use
      find -size -2k
  to find it, it does.  It seems like the parsing of units is wrong when you 
use 'k' for the size units.

  $ ls -l testf*
  -rw-rw---- 1 luke kendall 1071 Oct 26 17:06 testf
  -rw-rw---- 1 luke kendall  803 Oct 26 17:07 testf2
  -rw-rw---- 1 luke kendall  963 Oct 26 17:07 testf3
  $ find testf3 -size -1k -print
  $ find testf3 -size -2k -print
  $ find testf -size -2k -print
  $ find testf -size -3k -print
  $ find --version
  find (GNU findutils) 4.4.2
  Copyright (C) 2007 Free Software Foundation, Inc.
  License GPLv3+: GNU GPL version 3 or later <>
  This is free software: you are free to change and redistribute it.
  There is NO WARRANTY, to the extent permitted by law.

  Written by Eric B. Decker, James Youngman, and Kevin Dalley.
  Built using GNU gnulib version e5573b1bad88bfabcda181b9e0125fb0c52b7d3b
  Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION FTS() 

  $ lsb_release -rd
  Description:  Ubuntu 14.04.1 LTS
  Release:      14.04
  Package name is findutils

  I expected find -size -Nk to list a file if it is smaller than N kb.
  Instead, the file is only listed if it is smaller than (N+1) kb.

To manage notifications about this bug go to:

Mailing list:
Post to     :
Unsubscribe :
More help   :

Reply via email to