Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm not sure I am using ZSH's globbing correctly, but I thought ls *(/) would just list the dirctories under pwd, but it doesn't, it recursively lists all files under every directory under pwd (I got the statement from this list of useful zsh tips)

What would be right globbing for exclusively listing the directories under my current path?

share|improve this question

2 Answers 2

up vote 8 down vote accepted

I suspect the problem is not the zsh globbing, but the ls default behavior, that when given a directory argument list the content of directory.

I suggest to try

ls -d -- <your-glob-here>

The best way to test your globs is with

printf '%s\n' <glob>
share|improve this answer

@enzotib is right, and with that in mind, the command that lists directories under pwd in zsh is:

ls .(/)

share|improve this answer
No, ls .(/) lists the contents of the current directory (directories and non-directories alike). Since . is always a directory, this pattern is equivalent to .. –  Gilles Sep 1 '11 at 23:51
Thanks @Guilles, I think you are right. I'm happy to leave my answer in case anyone makes the same mistake. –  Amelio Vazquez-Reina Sep 1 '11 at 23:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.