FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > CentOS > CentOS

 
 
LinkBack Thread Tools
 
Old 10-17-2008, 09:30 AM
Jussi Hirvi
 
Default ls and rm: "argument list too long"

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.

Is there a way to go round this problem?

I have CentOS 5.2.

- Jussi

--
Jussi Hirvi * Green Spot
Topeliuksenkatu 15 C * 00250 Helsinki * Finland
Tel. & fax +358 9 493 981 * Mobile +358 40 771 2098 (only sms)
jussi.hirvi@greenspot.fi * http://www.greenspot.fi

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-17-2008, 09:36 AM
"Laurent Wandrebeck"
 
Default ls and rm: "argument list too long"

2008/10/17 Jussi Hirvi <greenspot@greenspot.fi>:
> 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.
>
> Is there a way to go round this problem?
>
> I have CentOS 5.2.
>
> - Jussi
try something like:
for i in /var/amavis/tmp/*
do
rm -rf $i
done

Laurent
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-17-2008, 09:55 AM
Lawrence Guirre
 
Default ls and rm: "argument list too long"

piping ls to xargs should do the trick. man xargs for details.

Jussi Hirvi wrote:

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.

Is there a way to go round this problem?

I have CentOS 5.2.


- Jussi

--
Jussi Hirvi * Green Spot
Topeliuksenkatu 15 C * 00250 Helsinki * Finland
Tel. & fax +358 9 493 981 * Mobile +358 40 771 2098 (only sms)
jussi.hirvi@greenspot.fi * http://www.greenspot.fi

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




_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-17-2008, 10:18 AM
Paul Bijnens
 
Default ls and rm: "argument list too long"

On 2008-10-17 11:30, Jussi Hirvi wrote:

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.

Is there a way to go round this problem?

I have CentOS 5.2.


I believe you gave a bad example!
In the command

rm -rf /var/amavis/tmp

the argument list is not at all "very long".
However if you did:

rm -rf /var/amavis/tmp/*

then the argument list could be very long depending on the number of
entries there are in the subdirectory.

You have to understand that globbing is done by the shell before
starting the command. The result of the glob is what makes the
"argument list too long"; it needs to fit in a buffer (about
128K bytes on a default CentOS install I believe).

If you want the to remove the subfolders and files, and not the parent
folder itself, on CentOS 5, try this:

cd /var/amavis/tmp
rm -rf *

Doing a "cd" makes the resulting of the globbing much shorter, maybe
fixing your problem already.

If still too long, then try:

find . -maxdepth 1 -exec rm -rf {} +

You could even try things like:

cd /var/amavis/tmp
rm a*
rm *0
...etc...

Any glob pattern resulting in less arguments for the command to avoid
overflowing the 128K buffer is good.

On CentOS 4, the '+' variant of -exec does not exist, and you need to do:

find . -maxdepth 1 -exec rm -rf {} ; # one rm command for each arg
or
find . -maxdepth 1 -print0 | xargs -0 rm -rf # less resource intensive

--
Paul Bijnens, xplanation Technology Services Tel +32 16 397.511
Technologielaan 21 bus 2, B-3001 Leuven, BELGIUM Fax +32 16 397.512
http://www.xplanation.com/ email: Paul.Bijnens@xplanation.com
************************************************** *********************
* I think I've got the hang of it now: exit, ^D, ^C, ^, ^Z, ^Q, ^^, *
* F6, quit, ZZ, :q, :q!, M-Z, ^X^C, logoff, logout, close, bye, /bye, *
* stop, end, F3, ~., ^]c, +++ ATH, disconnect, halt, abort, hangup, *
* PF4, F20, ^X^X, :, KJOB, F14-f-e, F8-e, kill -1 $$, shutdown, *
* init 0, kill -9 1, Alt-F4, Ctrl-Alt-Del, AltGr-NumLock, Stop-A, ... *
* ... "Are you sure?" ... YES ... Phew ... I'm out *
************************************************** *********************
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-17-2008, 10:33 AM
Jussi Hirvi
 
Default ls and rm: "argument list too long"

Lawrence Guirre (lawrence.guirre@gmail.com) kirjoitteli (17.10.2008 12:55):
> piping ls to xargs should do the trick. man xargs for details.

Ok, thanks for ideas, Laurent and Lawrence.

A strange limitation in ls and rm, though. My friend said he hasn't seen
that in Fedora.

- Jussi

--
Jussi Hirvi * Green Spot
Topeliuksenkatu 15 C * 00250 Helsinki * Finland
Tel. & fax +358 9 493 981 * Mobile +358 40 771 2098 (only sms)
jussi.hirvi@greenspot.fi * http://www.greenspot.fi

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-17-2008, 10:48 AM
"Geoff Galitz"
 
Default ls and rm: "argument list too long"

>> piping ls to xargs should do the trick. man xargs for details.

>Ok, thanks for ideas, Laurent and Lawrence.

>A strange limitation in ls and rm, though. My friend said he hasn't seen
>that in Fedora.


Are you sure you are comparing apples to apples? There is nothing
particularly Centos specific about this problem. I've seen it on a variety
of *NIX systems over the years, though I presume some distributions or UNIX
variants may have upped the buffer size.

Here is an interesting blog post which illustrates how you can get into this
kind trouble:

http://stevenroddis.com/2006/10/07/binrm-argument-list-too-long/index.html



-geoff




_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-17-2008, 10:53 AM
Ralph Angenendt
 
Default ls and rm: "argument list too long"

Jussi Hirvi wrote:
> Lawrence Guirre (lawrence.guirre@gmail.com) kirjoitteli (17.10.2008 12:55):
> > piping ls to xargs should do the trick. man xargs for details.
>
> Ok, thanks for ideas, Laurent and Lawrence.
>
> A strange limitation in ls and rm, though. My friend said he hasn't seen
> that in Fedora.

Than he doesn't have as many files in the directory as you have:

#define ARG_MAX 131072 /* # bytes of args + environ for exec() */

That's from /usr/include/linux/limits.h.
Also see <http://partmaps.org/era/unix/arg-max.html>

Ralph
_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-17-2008, 11:09 AM
Jeremy Sanders
 
Default ls and rm: "argument list too long"

Jussi Hirvi wrote:

> Lawrence Guirre (lawrence.guirre@gmail.com)
> kirjoitteli (17.10.2008 12:55):
>> piping ls to xargs should do the trick. man xargs for details.
>
> Ok, thanks for ideas, Laurent and Lawrence.
>
> A strange limitation in ls and rm, though. My friend said he hasn't seen
> that in Fedora.

This limitation has been removed from more recent kernels.

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b6a2fea39318e43fee84fa7b0b90d68 bed92d2ba

http://www.gnu.org/software/coreutils/faq/#Argument-list-too-long

Jeremy

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-17-2008, 12:47 PM
Les Mikesell
 
Default ls and rm: "argument list too long"

Jeremy Sanders wrote:


piping ls to xargs should do the trick. man xargs for details.

Ok, thanks for ideas, Laurent and Lawrence.

A strange limitation in ls and rm, though. My friend said he hasn't seen
that in Fedora.


This limitation has been removed from more recent kernels.

http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=b6a2fea39318e43fee84fa7b0b90d68 bed92d2ba

http://www.gnu.org/software/coreutils/faq/#Argument-list-too-long


It is probably still best not to expect the ability to build infinitely
long command lines. You can hit some other limit eventually.


--
Les Mikesell
lesmikesell@gmail.com

_______________________________________________
CentOS mailing list
CentOS@centos.org
http://lists.centos.org/mailman/listinfo/centos
 
Old 10-17-2008, 12:57 PM
Jussi Hirvi
 
Default ls and rm: "argument list too long"

Yes, you are right - my example was misleading.

Thanks for the very easy solution (cd into directory). Have to try it the
next time.

- Jussi

Paul Bijnens (Paul.Bijnens@xplanation.com) kirjoitteli (17.10.2008 13:18):
> I believe you gave a bad example!
> In the command
>
> rm -rf /var/amavis/tmp
>
> the argument list is not at all "very long".
> However if you did:
>
> rm -rf /var/amavis/tmp/*
>
> then the argument list could be very long depending on the number of
> entries there are in the subdirectory.

--
Jussi Hirvi * Green Spot
Topeliuksenkatu 15 C * 00250 Helsinki * Finland
Tel. & fax +358 9 493 981 * Mobile +358 40 771 2098 (only sms)
jussi.hirvi@greenspot.fi * http://www.greenspot.fi

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

Thread Tools




All times are GMT. The time now is 09:39 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org