Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • $(set -f; echo "$1"/*) seems a rather complicated way of writing "$1/*". And this won't match hidden directories or files. Commented Dec 11, 2019 at 1:36
  • What I meant is that there is no filename expansion in "$1/*" (note the quotes include *), so the set -f and subshell are unnecessary for that in particular. Commented Dec 11, 2019 at 1:55
  • It answers a different question: whether the directory contains non hidden files or directories. I am sorry about that. I will be happy to delete it. Commented Dec 11, 2019 at 2:01
  • 1
    There are ways to match hidden files too (see the complicated glob in mikeserv's answer: ./* ./.[!.]* ./..?*). Maybe you can incorporate that to make the function complete. Commented Dec 11, 2019 at 2:03
  • Ah ! I will look at this and learn and maybe we will have a complete answer based on globbing expansion ! Commented Dec 11, 2019 at 2:06