Delete Files in Bulk with find -exec
Combine find and rm -f {} + to remove every matching file without an argument-list error.
01Command
$ find ./logs -name "*.tmp" -type f -exec rm -f {} +02What it does
find builds the list of matches itself and -exec rm -f {} + passes them to rm in large batches, so you avoid the classic 'argument list too long' error from rm *.log on a directory with millions of files. The + form is more efficient than \; which launches one rm per file. Always run the find part without -exec first to preview exactly what will be deleted.
03Risk
04Undo
✓No undo needed — this command does not change persistent state.
05Sources
- find(1) — man7.orgEvidence: Man page documents the -exec action, the {} placeholder, the + form that batches matches into one invocation, and -delete
- find(1) — Ubuntu manpageEvidence: Ubuntu manpage describes -exec and -execdir actions with {} placeholder and batching with +
Last verified: 2026-09-19 · Category: Files & Folders
06Related solutions
Find every occurrence of a pattern across all files in a tree, printed as file:line:number matches.
Unpack a gzipped tarball into the current directory while printing each file as it is extracted.
Show total, used, and available space plus usage percentage for every mounted filesystem in human-readable units.