[CentOS] ls and rm: "argument list too long"
Kevin Krieser
k_krieser at sbcglobal.net
Sun Oct 19 01:28:45 UTC 2008
On Oct 18, 2008, at 8:13 PM, mouss wrote:
> Jussi Hirvi a écrit :
>> Since when is there a limit in how long directory listings CentOS
>> can show
>> (ls), or how large directories can be removed (rm). It is really
>> annoying to
>> say, for example
>>
>> rm -rf /var/amavis/tmp
>>
>> and get only "argument list too long" as feedback.
>
>
> I doubt this. "argument list too long" is a shell error, and in your
> command the shell doesn't see many arguments.
>
> I guess you want to remove amavisd-new temp files and you did
> rm -rf /var/amavis/tmp/*
>
> In this case, the shell would need to replace that with
> rm -rf /var/amavis/tmp/foo1 /var/amavis/tmp/foo2 ....
> in which case, it needs to store these arguments in memory. so it
> would
> need to allocate enough memory for all these before passing them to
> the
> rm command. so a limitation is necessary to avoid consuming all your
> memory. This limitation exists on all unix systems that I have seen.
>
>
>>
>> Is there a way to go round this problem?
>>
>
> Since amavisd-new temp files have no spaces in them, you can do
> for f in in /var/amavis/tmp/*; do rm -rf $f; done
> (Here, the shell does the loop, so doesn't need to expand the list at
> once).
>
> alternatively, you could remove the whole directory (rm -rf
> /var/amavis/tmp) and recreate it (don't forget to reset the owner and
> permisions).
>
>
>
>> I have CentOS 5.2.
>>
Possible to learn something new every day. I would have expected the
for loop to fail too, thinking it would attempt to expand the wildcard
before starting it's iteration.
More information about the CentOS
mailing list