I was originally unconvinced that the question was on-topic. I didn't have a strong opinion either way: I wouldn't have voted to close it, but I wasn't sure that I should re-open it, either.
However, the discussion in the comments has served to convince me that the question is on-topic, or at least that it could be made so with a few minor edits. Jonathan Leffler's comment was ultimately the most persuasive:
In my opinion, the question is on-topic for SO. It is about how to write a shell script. It isn't directly couched in terms of a shell script, but it is more than plausible that the objective is to get a full list of file names for use in some more shell code. The answers seem good; several have considerable up-votes. I'm not at all convinced it should have been closed 'off-topic'. There was a period (somewhere about the time this got closed, give or take a year or two) when some people got horribly itchy fingers about closing shell-related questions as OT. They're not OT in my opinion.
In particular, his observation that the answers are of high quality. There are no glaring problems with this question or the answers it has and may attract that could serve to justify a historical lock. Providing this information, and letting the community curate it, serves our goal of making the Internet a better place.
As such, I've unlocked and re-opened it.
I also made some excessively trivial edits to get the words "shell scripting" in there. If someone who is more of an expert than me can make it clearer that this is on-topic for Stack Overflow, please be my guest.
Nota Bene: I'm sure that some folks will disagree with my action here. Please express your disagreement by posting an answer to this question, rather than by embarking on a close-delete war on the main site. If the pendulum of consensus swings the other way, I will be happy to reverse my own action as dictated by the community. But close-delete wars serve no one, at least in part because there is no way to make an actual argument defending your viewpoint.