Given a directory projects/
whose subfolders may have a venv/
folder at variable depths
projects/foo/src/venv/ # venv/ at depth 2
projects/bar/venv/ # venv/ at depth 1
projects/baz/src/core/venv # venv/ at depth 3
projects/woo/ # venv/ non-existent
How can I recursively search and delete any venv/
folders that exist at any depth within projects/
and it's subfolders?
I've tried
~/projects $ find . -name venv -type d -exec rm -rf {} \;
but receive the error
find: ‘./foo/venv’: No such file or directory
It seems to only search the most immediate subfolder, and because venv/
is inside of foo/src/
rather than simply foo/
, it fails.
I need a command that will do an exhaustive recursive search throughout the entire folder tree.
-depth
to the command was an easy fix. I unfortunately can't submit that as an answer now though, given that the mods closed this as a duplicate. – Michael Moreno Mar 18 '23 at 08:35