Let's say I need to find this path /<some_where_in_root>/find/this/path and the only information I have is /find/this/path. What would be the best means of locating the full directory?

I basically have a program that creates a directory and after the directory is created I'd like to see if a path now exist within the directory that was created.

So far I've tried find . -type d -name "/find/this/path" but this obviously interprets /find/this/path as a string. Is there any way to use find in this situation? Would it be best to just parse the path I have and take the path portion and do a search on this string?

4 Answers 4


You need to use -path or -ipath with wildcards

find . -type d -ipath "*/find/this/path"

The -path predicate (and it's case-insensitive variant, -ipath) will allow you to search the entire tree for that exact text.

  • That's what I thought, but it is now obvious to me that I've been doing it incorrectly. I've tried find . -ipath "/find/this/path" Jun 17, 2013 at 2:20

execute these two commands, method1:

root@developer~:# updatedb

root@developer~:# locate /find/this/path


root@developer~:# tree |grep /find/this/path

the results will consists full path of /find/this/path

also try this run these from /

root@developer~:# cd /

root@developer~:/#locate /find/this/path
root@developer~:/#tree |grep /find/this/path

works in all flavors of nix:

applemcg.$ find / -type d -name this | grep find/this/path

and a little advice, when asking for help. preface your first reference to a path of this sort with the word "directory", as in "directory path". it took a minute to realize you were not referring to the (csh) path or PATH variable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.