ZSH – ls *(.) Lists Regular Files Only but ls *(/) Does Not List Directories Only

lszsh

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?

Best Answer

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>

or

print -rC1 -- <glob>