find walks one or more start paths and evaluates predicates: -name, -type, -mtime, -size, and more. Combine tests with -a and -o; parentheses need escaping in shells. -exec cmd {} + batches paths for efficiency versus \; per file. Use -print0 with xargs -0 for safe whitespace handling. -prune skips subtrees such as .git or node_modules.
| Pattern | Example | Why |
|---|---|---|
| Batch exec | find . -type f -exec grep -H pattern {} + | Fewer processes than per-file exec |
| Safe paths | find . -print0 | xargs -0 rm | Handles spaces/newlines in names |
| Skip dir | path -prune -o … -print | Avoid expensive subtrees |