Re: [Fwd: Re: The directory that I am trying to clean up is huge]

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



James B. Byrne wrote:
 > On Sat, January 23, 2010 20:21, Robert Nichols wrote:
 >> Robert Heller wrote:
 >
 >> Gosh, then I guess the manpage for 'find' must be totally wrong
 >> where it
 >> says:
 >>
 >>         -exec command ;
 >>                ...
 >>                The specified command is run once for each matched
 >> file.
 >>
 >
 > Not wrong.  The man page on find simply does not speak to the limits
 > of the kernal configuration (MAX_ARG_PAGES) implicitly used by cp,
 > find, ls, etc.  It just lives within its means and fails when these
 > do not suffice.
 >
 > The problem you have is that the selection of all qualified files is
 > completed before any are acted on by find.  So, in the case of
 > overlarge collections, the page limit is exceeded before any are
 > deleted.  Taking each file as it is found and piping it to an
 > external rm command avoids hitting the page limit.

When using the -exec action with the ";" terminator, the constructed
command line always contains the path for exactly one matched file.
Try it.  Run "find /usr -exec echo {} ;" and see that you get one
path per line and output begins almost instantly.  Do you really
believe that 'find' searched the entire /usr tree in that time?

Now if the "{}" string appears more than once then the command line
contains that path more than once, but it is essentially impossible
to exceed the kernel's MAX_ARG_PAGES this way.

The only issue with using "-exec command {} ;" for a huge number of
files is one of performance.  If there are 100,000 matched files,
the command will be invoked 100,000 times.

-- 
Bob Nichols     "NOSPAM" is really part of my email address.
                 Do NOT delete it.

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux