Mailinglist Archive: opensuse (2459 mails)

< Previous Next >
Re: [opensuse] /bin/rm: Argument list too long

----- Original Message -----
From: "Per Jessen" <per@xxxxxxxxxxxx>
To: <opensuse@xxxxxxxxxxxx>
Sent: Thursday, March 27, 2008 3:23 PM
Subject: Re: [opensuse] /bin/rm: Argument list too long

Anders Johansson wrote:

But the thing is, the xarg's man page does not clearly say that it
joins arguments up to the size limit. There are hints that concurs
with that fact, but it is not clearly stated :-)

Exactly - in particular, the '-0' argument doesn't say anything about
matching any size limit.

Possibly because that's not what -0 does. -0 just tells xargs to not
use blanks or newlines as parameter separator, but to wait for a null
character instead

Ah, now I'm beginning to see your point. I would have _sworn_ that
"| xargs <cmd>" did not take the max # arguments into account, which is
why I thought '-0' somehow altered that.
But I am clearly wrong - "| xargs <cmd>" _does_ know about max number of

I still feel certain I've done stuff like:

find <dir> -type f | xargs zgrep -i blah

and seen something like "too many arguments" or whatever it is, but of
course I can't reproduce that now.


If you run:
find /path/to/foo -type f -name foo* | xargs zgrep -i blah
in the wrong place, you will still get arg list too long.
That is why it's always:
find /path/to/foo -type f -name 'foo*' | xargs zgrep -i blah

I have seen scripts that are part of expensive commercial software that did
just that.
They used xargs to process a list of unpredictable size - good!
They used shell globbing characters to generate the list - bonehead!
...Then they go on in the same script to use chown and chmod in backwards order
such that chown undoes what chmod did.

If you don't use find -print0 |xargs -0
then any files with spaces in the names will look like seperate files (which
don't exist) to whatever command you ran with xargs.

If you have filenames with globbing characters in them (this is legal), then
they may be handled ok by find and xargs and then be expanded by the shell on
the command line that xargs created, thus increasing the command line beyond
the maximum since xargs would have created a line that was already maxxed out.

It's also possible for there to be discrepencies between the app being run by
xargs, and the rest of the system. Maybe the shell and the kernel will tolerate
up to 4k (I think it's more like 100 or 400 but no matter) so xargs generates
4k command lines, but maybe appfoo can only handle 1k ?

There are probably lots of odd ways to to cause the message or similar ones
despite the utils working perfectly as advertised.
There is nothing wrong in any of that, it's up to you to know what you are
doing, or at least be prepared to figure out what you did wrong in 99.9999% of
the times when some util doesn't do what you expected. :)

Brian K. White brian@xxxxxxxxx
filePro BBx Linux SCO FreeBSD #callahans Satriani Filk!

To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups