bash limits ?

Peter L. Peres plp-ysDPMY98cNQDDBjDh4tngg at public.gmane.org
Fri Sep 10 00:28:13 UTC 2004


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 ?

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, 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
 	...
done

I am not sure where it fails. 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).

thanks,

Peter
--
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