You can use the find
command to find folders with the -type d
parameter. Here are a few examples:
#Search Root ( / ) folder for a folder called www
nits@excalibur:~$ sudo find / -name www -type d
/media/6E5E0E255E0DE6A5/cygwin/srv/www
/media/6E5E0E255E0DE6A5/cygwin/usr/share/doc/ImageMagick-6.4.0.6/www
/media/6E5E0E255E0DE6A5/cygwin/usr/share/doc/GraphicsMagick/www
/media/6E5E0E255E0DE6A5/cygwin/var/www
/media/6E5E0E255E0DE6A5/wamp/www
#Search current folder for a folder which start either Capital/lower-case M
nits@excalibur:~$ find . -iname m* -type d
./.local/share/telepathy/mission-control
./.config/menus
./.mozilla/firefox/vwfuj46p.default/minidumps
./.cache/indicators/messages
./.cache/chromium/Default/Media Cache
./Music
./.macromedia/Flash_Player/macromedia.com
./.jedit/macros
./.jedit/modes
./.gconf/apps/metacity
In the above examples, you would have noticed that only the directories with no subdirectories in them are listed. You can use mindepth/maxdepth
to set the depth of the level that needs to be traversed.
#Search current directory for directories starting with either capital/lower-case M but only are present in the current directory
nits@excalibur:~$ find . -maxdepth 1 -iname m* -type d
./Music
# Traverse two levels (current level and one level under) in the current directory for directories starting with either capital/lower-case M:
nits@excalibur:~$ find . -maxdepth 2 -iname m* -type d
./.config/menus
./Music
./.jedit/macros
./.jedit/modes
There are a whole load of different options to search directories and files as well using find
, you can look through the man-page accessible by man find
for all the options and how to use it. Also although find
is slower than locate
it doesn't require updatedb
to update a DB to search through because the search is performed real-time.