limit to number of files seen by ls?

Karl Vogel vogelke+unix at
Thu Jul 23 17:44:39 UTC 2009

>> On Wed, 22 Jul 2009 20:01:57 -0400, 
>> John Almberg <jalmberg at> said:

J> A client has a directory with a big-ish number of jpgs... maybe 4000.
J> Problem is, I can only see 2329 of them with ls, and I'm running into
J> other problems, I think.

J> Question: Is there some limit to the number of files that a directory
J> can contain? Or rather, is there some number where things like ls start
J> working incorrectly?

   Every version of Unix I've ever used had an upper limit on the size
   of the argument list you could pass to a program, so it won't just be
   "ls" that's affected here.  That's why I use 1,000 as a rule of thumb
   for the maximum number of files I put in a directory.

   A longer-term fix for your client would be to break up that JPEG file
   list into smaller sets based on (say) date or image topic or whatever.

Karl Vogel                      I don't speak for the USAF or my company
Al Capone's business card said he was a used furniture dealer.
                                        --item for a lull in conversation

More information about the freebsd-questions mailing list