http://qs321.pair.com?node_id=707269


in reply to greater efficiency required (ls, glob, or readdir?)

If the directory is large and you want to do globbing of file names, then ls can be a bad idea. From the shell:

-> ls | wc -l 61498 -> ls * bash: /bin/ls: Arg list too long
You wouldn't actually do this to get the full directory listing, of course, but if the list of something*.whatever files that you want is too long, you're still hosed. In that case, you want a readdir / grep combo or glob (which doesn't suffer the same limitation as ls).