bug-bash
[Top][All Lists]
Advanced

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

Re: Argument list too long (how to remove the limit)


From: Stephane CHAZELAS
Subject: Re: Argument list too long (how to remove the limit)
Date: Tue, 26 Jan 2010 19:47:14 +0000 (UTC)
User-agent: slrn/pre1.0.0-16 (Linux)

2010-01-25, 18:03(-06), Peng Yu:
> I got the following message. Is there a way to configure bash such
> that there is not a limit like this?
>
> /bin/bash: Argument list too long
[...]

That's a limitation of the execve(2) system call on some
operating systems. GNU Hurd and recent versions of Linux are
known not to have that limitation.

It's a limitation on the cumulative size of the arguments and
environment passed to an executed command. The limit varies
between systems.

To work around it, you may have to run several instances of the
same command, with a subset of the argument list each time.
zsh's zargs or xargs or find  may come handy.

For instance, instead of:

rm ./*

Try:

find . ! -name . -prune ! -name '.*' -exec rm {} +


Instead of

rm /very/long/path/to/some/directory/*

try:

cd /very/long/path/to/some/directory && rm -- *

Also, as it's a limit on the execve(2) system call, it doesn't
apply to shell builtins. So, if you're using zsh, you could use
the zsh/files module to have most of the stanard file handling
commands builtin:

zmodload zsh/files
rm -- *


-- 
Stéphane


reply via email to

[Prev in Thread] Current Thread [Next in Thread]