John Almberg wrote:
I seem to have run into an odd problem...

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

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

There's a limit to the number of arguments the shell will deal with
for one command.  So if you type:

   % ls -lh *

(meaning the shell expands '*' to a list of filenames), you'll run into
that limitation.  However, if you type

   % ls -lh

and let ls(1) read the directory contents itself, it should cope
with 4000 items easily.  [It might slow down because of sorting the
results, but for only 4000 items that's probably not significant]

Now, if your problem is that these 4000 jpegs are mixed up with other
files and you only want to list the jpeg files, then you could do
something like this:

   % find . -name '*.jpeg' -print0 | xargs -0 ls -lh

or even just:

   % find . -name '*.jpg' -ls

        Cheers,

        Matthew

--
Dr Matthew J Seaman MA, D.Phil.                   7 Priory Courtyard
                                                 Flat 3
PGP: http://www.infracaninophile.co.uk/pgpkey     Ramsgate
                                                 Kent, CT11 9PW

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to