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

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



I think the maximum length of shell commands is up to 4096 characters now, but I am not certain.

Having a very large number of files in a few directories is not good. Eventually you will notice performance degredation. Try to rename and/or split your files into a hierarchy of directories. You can acheive a very slick ordering of files this way. For example, assume you have a weather map (.jpg) for each US zip code. There are roughly 99k of these images. Having all of those in a single directory will create on hell of a mess.

Name the images using the last two digits of the zip (e.g. 04.jpg) and place it in the appropriate directory:

/images/2/3/6/04.jpg

Bingo! It's simple to locate the weather map for zip 23604.

In this manner, no directory has more than ten subdirectories and no directory contains more than 100 files. Your filesystem will thank you and you will find yourself writing scripts to manage the data extremely common sense.

In general, if you need to re-compile the most basic utilities (ls, cp, mv, etc.) your problems are elsewhere.

--Randy


On Tuesday, December 10, 2002, at 11: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?

Thanks in advance,
Adam

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



_______________________________________________
Valhalla-list mailing list
Valhalla-list redhat com
https://listman.redhat.com/mailman/listinfo/valhalla-list





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