Search with "grep" for folder names

I usually use find:

$ find . -name 'FolderBasename*' -type d

or for more complex queries

$ find . -regex '{FolderRegex}' -type d

As pointed out in the comments if you want case insensitive searches do -iname and -iregex


If you really mean regexp instead of shellglob, you may want to use

find <path> -regex <regex> -type d

eg.

find Code/ -E -regex '(bin|redblack)_tree\.hs' -type d

the option -E turns on extendend regexp, see man find for more.


If you are just concerned with matching the name you can simply use '-name' in find.

find <path> -name '<regex>' -type d

find is far better but a clunky answer to your question:

ls -l | grep '^d'