
マゼントルーティングにはadminhtml/routes.xml
各モジュールにadminhtml
ファイル名の付いたフォルダがあり、routes.xml
各モジュールには独自のフォルダがあります。つまり、次のようなファイル構造を持ちます。
vendor
+ MyModule
++ etc
+++ adminhtml
++++ routes.xml
+ AnotherModule
++ etc
+++ adminhtml
++++ routes.xml
....
vendor
ディレクトリをスキャンして、どのファイルパスに特定の単語route.xml
があるかを確認したいと思います。
$ find ./vendor -name adminhtml\/routes.xml -exec grep "sales" {} +
しかし、何の価値も得られず、次の警告も表示されます。
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’?
特定のフォルダパターンに特定の単語を含むファイルを見つける方法は?
答え1
あなたは以下を行う必要があります-path
:
find ./vendor -path '*/adminhtml/routes.xml' -exec grep "sales" {} +
(おそらく-type f
というディレクトリがある可能性はほとんどありませんroutes.xml
。)
答え2
私が取ったアプローチの1つは、routes.xml
名前と一致し、必要なwotdを含むすべてのファイルをフィルタリングし、次にgrepを使用してfind結果をさらにフィルタリングすることです。
find ./vendor -name routes.xml -exec grep "sales" {} + | grep adminhtml
その後、IDEを使用してファイルを開き、さらに編集/分析できます。