「-pattern」で「find」を使用し、深さを制限する方法は?

「-pattern」で「find」を使用し、深さを制限する方法は?

私が知る限り、これは次のようになります。

find . -path \*/pages/*/index.css

あなたは見つけるでしょう:

./lib/pages/home/index.css
./lib/pages/home/lib/header/index.css

私が本当に欲しいのは、次を見つけることです。

./lib/pages/home/index.css

そうなんでも/home/何でもいいけど/about//checkout/

そのフラグを使用しようとすると、次の結果-maxdepthが表示されます。

find: warning: you have specified the -maxdepth option after a non-option argument -path, but options are not positional (-maxdepth affects tests specified before it as well as those specified after it).  Please specify options before other arguments.

ベストアンサー1

助けてくれたGoldilocksのおかげで-maxdepth問題は解決しました。問題は-maxdepth私が-path。次の構文は期待どおりに機能します。

find . -maxdepth 1 -path \*/pages/*/index.css

おすすめ記事