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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Once upon a time, Rick Stevens <ricks@xxxxxxxx> said:
> On 03/25/2010 10:44 AM, Patrick O'Callaghan wrote:
> > On Thu, 2010-03-25 at 10:21 -0700, Rick Stevens wrote:
> >>          # find /etc -size 1G -exec ls -lh \{\} \;
> >>
> >> run as root finds files<1G as confirmed by the "ls" bit of the
> >> command.
> >
> > The OP's test (and mine) was with "-size -1G". Your test uses "-size 1G"
> > but (incorrectly) gives the result expected for "-size -1G".
> >
> > This really should be reported. It would be appropriate for the OP to do
> > so as he found it.
> 
> You are correct.  Doing "-size -1G" on both F11 and F12 return only
> zero-length files.  Yep, that's a bug in my book.

Looking at the source, it is happening because of the way the size
suffix is implemented.  With no suffix, find works in increments of a
blocksize of 512 (the file size in bytes is rounded up to the next
integer multiple of the blocksize); "find -size 1" would find all files
with a size from 1 to 512 bytes, inclusive, and "find -size -1" would
find files with a size less than 1 (e.g. 0).

GNU find implements the suffixes by changing the blocksize.  So, 1G is
interpreted as size from 1 to 1024*1024*1024 bytes.  -1G means smaller
than that, so still only size 0 matches.

While this gives less-than-intuitive results, this is the documented
behavior (although the documentation could be clearer).

-- 
Chris Adams <cmadams@xxxxxxxxxx>
Systems and Network Administrator - HiWAAY Internet Services
I don't speak for anybody but myself - that's enough trouble.
-- 
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [Fedora Magazine]     [Fedora News]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Maintainers]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Legacy]     [Fedora Desktop]     [Fedora Fonts]     [ATA RAID]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [SSH]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Centos]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Tux]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Asterisk PBX]     [Fedora Sparc]     [Fedora Universal Network Connector]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux