How to locate a path

locate

Is it possible to locate a path in the file system like what can be done for file names? For example I want to find all paths in system that include 'foo/bar', which may have the following result:

/home/myname/test/foo/bar/hello
/var/www/site/foo/bar

Best Answer

If you are unable to find the file with the below command then try updatedb for updating db used by locate command.

locate -r foot/bar/

or

# locate  "/*/bar/avi"
/foot/bar/avi

find command can also do this

find / -path */foot/bar*

find / will search the whole system starting from /