limit to number of files seen by ls?
m.seaman at infracaninophile.co.uk
Thu Jul 23 07:21:37 UTC 2009
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
Dr Matthew J Seaman MA, D.Phil. 7 Priory Courtyard
PGP: http://www.infracaninophile.co.uk/pgpkey Ramsgate
Kent, CT11 9PW
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 259 bytes
Desc: OpenPGP digital signature
Url : http://lists.freebsd.org/pipermail/freebsd-questions/attachments/20090723/cf011958/signature.pgp
More information about the freebsd-questions