How to find files with a certain subpath

consolefile searchfindgrepregular expression

I need to find all xml-files that are placed in folders named config. Also config must be somewhere under a folder named trunk. For example, I am interested in all files like below:

~/projects/e7/trunk/a/b/c/config/foo.xml
~/projects/d/trunk/config/bar.xml
~/projects/trunk/config/other.xml
~/projects/e/e/e/trunk/e/e/e/e/e/e/e/e/config/eeeee.xml

I tried the find command:

find ~/projects -regex "*/trunk/*/config/*.xml"

, but the output was empty. What is the correct way to find the required files?

Best Answer

That's not a regex. For globs one should use the -path predicate instead.

Related Question