Reputation: 4080
I'm trying to get a list of directories with the name vendor where the parent directory also contains a file with the name composer.json.
Some context:
For a simple backup script I want to exclude generated files/folders such as node_modules
(generated by NPM) and vendor
(generated by Composer).
I can simply exclude all folders with the name node_modules
because it is almost certain that it was generated by NPM. Though, the vendor
folder, created by Composer, is a very common name, so I want to check if there is a composer.json
file in the parent directory. If there is then I can assume that the vendor
folder was generated by Composer.
Is there an efficient way to achieve this?
Upvotes: 2
Views: 557
Reputation: 48672
This will work:
find -type d -name vendor -execdir test -e composer.json \; -print
Upvotes: 3