find Flags & Options
Search for files in a directory tree.All find pages
- find -exec {} + vs -exec {} \;: batch or one command per filefind -exec cmd {} + runs one command for many files; -exec cmd {} ';' runs one per file. Speed, exit status, where {} may go and missing argument errors.
- find -maxdepth 1: limit how deep find searches (and -mindepth)find -maxdepth 1 searches only the starting directory and its direct entries; -mindepth 1 drops the start itself. Values, global option warning, BSD notes.
- find -print0 | xargs -0: handle file names with spaces and newlinesfind -print0 | xargs -0 separates file names with NUL bytes, so names with spaces, quotes or newlines reach the command intact. Companion options and pitfalls.
- find -prune: exclude a directory such as node_modules or .gitfind -prune skips directories such as node_modules or .git without descending into them. Why -print is needed, -path prefixes, several names and pitfalls.