Search with “grep” for folder names

bashgrepsearchshell

When using grep you can search for a specific regex, but only inside of a file.
Is there any way, I can search for a folder name?

Best Answer

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

Related Question