bash limits ?

Chris F.A. Johnson c.f.a.johnson-bJEeYj9oJeDQT0dZR+AlfA at public.gmane.org
Thu Sep 9 17:49:51 UTC 2004


On Thu, 9 Sep 2004, Peter L. Peres wrote:
> On Thu, 9 Sep 2004, Chris F.A. Johnson wrote:
>> On Thu, 9 Sep 2004, Peter L. Peres wrote:
>> 
>>> Hi, where do I find the limits with which bash was compiled ? For older 
>>> and newer bashes ? I believe that I am trying to do something that 
>>> exceeds a hard compiled limit in bash and it fails in mysterious ways. 
>>> Specifically I have variables that contain lists of thousands of 
>>> numbers. Some of them seem to disappear ...
>>> 
>>> So what is the maximum number of arguments that can be passed to a for 
>>> ... construct, or their maximum length ? And what are the other limits 
>>> ?
>> 
>> Arguments to built-in commands (such as echo) and keywords (such as
>> for) are limited only by available memory.
>> 
>> The number of arguments that can be passed to external commands is
>> system-dependent.
>> 
>> $ echo {1..31111} > /dev/null
>> $ /bin/echo {1..21111} > /dev/null
>> $ /bin/echo {1..31111} > /dev/null
>> bash: /bin/echo: Argument list too long
>> $
>
> Thanks. Is the argument list too long, as in too many words, or too many 
> bytes in it ?

    I believe either or both can apply.

> In my program I have a set of directories with files in them. This follows a 
> naming structure represented as a regex like
>
> ../[0-9][0-9]/[0-9][0-9]/[0-9]{8}
>
> I read the names of all these files using 'ls .' or equivalent,

    If you are using ".", there should be no problem, but if you use
    wildcards, you could be passing too many arguments to ls.

> prune certain things, and pass the output to a for ... construct. It
> works for low file counts (~100 test case) and fails for high file
> counts (~2000). The program outline is like:
>
> for f in `ls .|cut -d'/' -2`; do

     Do you mean -f2? But the output of "ls ." will not contain any
     slashes.  What are you trying to do?

> 	...
> done
>
> I am not sure where it fails.

     What are the exact error messages (and the exact code)?

> I think that the argument list passed to for is too long but you
> seem to say that the argument list passed to for is not limited (it
> should be a temporary variable or the output of a pipe if I
> understand how bash works).

-- 
 	Chris F.A. Johnson                      http://cfaj.freeshell.org
 	=================================================================
                 Everything in moderation -- including moderation
--
The Toronto Linux Users Group.      Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml





More information about the Legacy mailing list