Find Directory only
From terminal I am looking for a way to use the find or grep command to find all occurrences of a specific directory name. I would like to strip out all files thus removing duplicate folder listings. So for example, if I wanted to see all the lib dirs on my computer, I couldn't just do:
find / lib As this not only shows all lib dirs but also would list directories multiple times due to certain ones have multiple files in the path. So I would want to just know that there is a dir called /var/lib and would not want the output to include /var/lib/gdm /var/lib/gdm/.cache /var/lib/rpm And so on. Thanks for any assistance. |
See the manpages for find(1) -- specifically, the type option.
|
Try find /path/to/search -type d -name 'DIRECTORY_NAME'. For example:
Code:
$ find /usr/ -type d -name 'doc' Lastly, be sure to try this: Code:
$ man find |
Adding -type d to the search criteria should do the trick. E.g.
Code:
find / -type d -name lib\* |
Thanks, I actually had looked at the man pages but must have missed the -type option.
|
All times are GMT -5. The time now is 04:55 PM. |