I want to use "find ... -delete" but from a certain depth. How can I say this to find?
- User
I want to use "find ... -delete" but from a certain depth. How can I say this to find?
Assistant
You can use the
-mindepthoption withfindto specify the minimum directory depth before applying-delete. Here's how:bashfind /path/to/search -mindepth 2 -name "*.tmp" -deleteThis would delete all
.tmpfiles starting from depth 2 (subdirectories of subdirectories).The depth levels work like this:
- Depth 0: The starting directory itself
- Depth 1: Direct children of the starting directory
- Depth 2: Grandchildren directories
- And so on...
You can also combine
-mindepthwith-maxdepthif you want to limit the range:bash
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.