[Novalug] any clever options on 'rm'

Nino Pereira pereira@speakeasy.net
Tue Oct 23 22:32:16 EDT 2007


Interesting, this question of limits to the length of the argument
list in a command. My original question was motivated by just such a
humongous directory as mentioned here.

In fact, I ran into a limit on 'rm' itself in my earlier attempt
(before the list gave me a better way of doing it) to delete unnecessary
files: 'argument list too long', it said. To circumvent this I simply
started to delete the files in batches, not simply 'rm *'
but 'rm pic-1*' ('cause the files came from 'pdfimages foo.pdf pic').
This worked, slowly: the list solution is much better.

Nino


Stuart D. Gathman wrote:
> On Tue, 23 Oct 2007, Joel Fouse wrote:
> 
>>> xargs never has too many args.  That is its whole point = eXtended ARGS.
>>> I runs the command multiple times, with a large argument list each time.
>>
>>
>> Are you quite sure?  When your 'find' command returns results in the
>> tens or hundreds of thousands, which all get shoved across the pipe for
>> xargs to tack onto the end of its command list to execute?  There is, I
>> believe, a hard-coded limit in the kernel for the amount of memory that
>> can be used for storing the argument list sent to any program, and when
>> you exceed it (such as when doing "ls *" on a huge-mungous dir) you get
>> the standard "Argument list too long" error.  I would have assumed xargs
>> would have been subject to this as well, not necessarily on the incoming
>> end so much as when it compiled the final list and executed it.
>>
>> I freely admit I may be wrong on this point, but I want us to be clear
>> on what we are saying.  Does xargs have a way to get around this limit
>> before it finally executes the requested command?
> 
> Use the "-t" (trace) option to xargs to see how it works.  There is indeed
> a memory limit for args.  Xargs fills it up from the input, runs the 
> command,
> then repeats as needed.  (Lather, rinse, repeat.) I would paste some output
> from -t, but the memory limit is rather large these days...
> 



More information about the Novalug mailing list