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*

6
  • 1
    By "length of the array" do you mean its number of elements? And do you want to get this without actually defining this array (* suggest you want to use shell globing mechanism here)? Commented Feb 9, 2019 at 1:36
  • Oops, you're right i should have asked the other way around, I'll edit it. Commented Feb 9, 2019 at 1:48
  • @Cristiano: zsh doesn't have anything to do with it. * is not an array in the way you are using it, it is a shell glob. Arrays have nothing to do with your question unless you create an array as Jeff did in his answer. Your question is "How do I find how many files are in the current directory" Commented Feb 9, 2019 at 1:49
  • @Jess_b But it acts like an array don't you think? echo *[0] in zsh prints the 1st file name... Commented Feb 9, 2019 at 2:07
  • @Cristiano: I believe that is a zsh specific glob qualifier but still doesn't make the glob an array Commented Feb 9, 2019 at 2:15