Using find in order to detect a magento module

At magento routes are located in adminhtml/routes.xml each module has a folder named adminhtml with a file routes.xml each module has its own folder. In other words I have the following file structure:

vendor
+ MyModule
++ etc
+++ adminhtml
++++ routes.xml
+ AnotherModule
++ etc
+++ adminhtml
++++ routes.xml
....

And I want to scan the vendor directory and look what pathes of files route.xml have a specific word:

$ find ./vendor -name adminhtml/routes.xml -exec grep "sales" {} + 

But I do not get any value and also I get the following warning:

find: warning: ‘-name’ matches against basenames only, but the given pattern contains a directory separator (‘/’), thus the expression will evaluate to false all the time.  Did you mean ‘-wholename’?

How I can find files located in a specific folder pattern and have specific words?

An approach of mine is to filter all files matching the routes.xml name and contain the required wotd then filter further the result of find with grep:

find ./vendor -name routes.xml -exec grep "sales" {} + | grep adminhtml

Then you can open the file using the IDE and edit it/analyze it further.

Answered By: Dimitrios Desyllas

You need -path instead:

find ./vendor -path '*/adminhtml/routes.xml' -exec grep "sales" {} + 

(Possibly with -type f, it’s not likely there will be a directory named routes.xml.)

Answered By: muru
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.