[find] Delete files that match a search

Created on November 30, 2026

Use find -delete to remove paths matching your conditions. This example deletes regular files ending in .tmp under work.

mkdir -p work
printf 'temporary\n' > work/a.tmp
printf 'keep\n' > work/b.log

find work -type f -name '*.tmp' -delete
find work -type f -print
work/b.log

-type f restricts the search to regular files. Preview the selection by using -print in place of -delete before deleting the results.

Reference

Shell command find