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

Re: bash: /bin/ls: Argument list too long



> From: Darrell Parlee <darrell parlee net>
> To: valhalla-list redhat com
> Subject: Re: bash: /bin/ls: Argument list too long
> 
> ls Pictures/*.jpg | wc -l
> 
> This will dramatically reduce the line length and hence solve your 
> problem. 

This just delays the problem until the number of items in the
directory increases to the point where you still reach the limit.


> As for your questions:
> 
> 1) I'm not sure what the "string limit" is, but do know it is built 
> into the shell.

No.  It's not in the shell; it's in the kernel which allocates
a 128KB buffer by default for the arguments to a single command.


> 2) The way to increase the limit would to be adjusting the appropriate 
> parameter in the source tree and rebuilding the shell. Not for the 
> faint of heart ...

You'd have to recompile the kernel to change the limit.  This is the
WRONG WAY to approach the problem, even if you're not faint of heart.

"find" and possibly "xargs" are your friends! :-)

See my response from a few minutes ago for more details.


> On Tuesday 10 December 2002 08:52 am, Adam Cormany wrote:
> > I have a directory called Pictures. Inside it is 8059
> > .jpg images. If I'm sitting inside the Pictures
> > directory, I can `ls -l *.jpg|wc -l` with no problem,
> > but if I'm sitting outside the directory and do `ls -l
> > Pictures/*.jpg|wc -l` I get "bash: /bin/ls: Argument
> > list too long". I think I understand why I'm getting
> > it. Basically with me adding *.jpg, the actual command
> > would be ls -l file1.jpg file2.jpg file3.jpg and so
> > forth, correct? I can do `ls Programs|wc` fine but I'm
> > sure even that will die after more images are added to
> > this directory.
> > 
> > My questions are:
> > 1) What is the max string length for ls?
> > 2) Is there a way to increase the max length for ls
> > arguments?
> > 
> > I realize I could make seperate directories and try to
> > seperate some of the images to reduce the size of
> > files in each directory, but I will still run into
> > this problem with commands like ls and find I would
> > think?
> > 

-- 
    pete peterson
    Teradyne, Inc.; 7 Technology Park Drive; Westford, MA 01886-0033
    +1-978-589-7478 (Office); +1-978-589-2088 (FAX);
    pete peterson teradyne com or petersonp genrad com

 





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