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


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

In theory, all solutions will boil down to a readdir (the system call), so it's likely to be the fastest.

In practice, the speed difference between the different methods is probably minor, so you should use the method you find easiest to use and maintain. If you find that too slow, *then* come to us.

My personal opinion is that running a child process to get a directory listing is a rather silly thing to do. I wouldn't use ls. Doubly so for using cat for reading a file!!!