Tasks I tend to forget how to perform with find(1) .

Delete matched files

The most trivial one: find <path> [..] -delete (e.g. find . -name foo -delete).

However, depending on the OS -delete might not be available. In that case, see the next one.

Execute command with matched files

find <path> [..]  -exec <cmd> '{}' \;

is executed once for each matched file and the relative path to it is replaces '{}' and I always forget that \;, which might be omitted depending on a bunch of weird shell-isms (e.g. find . -name foo -exec rm -f '{}' \;).

If you want to call <cmd> exactly once (with caveats) with all the matched files passed as argument, add + at the end, but then '{}' should be right at the end of the command just before the +: find . -type f -name 'foo*' -exec rm -f '{}' +

Match files by modification time

find <path> [..] -mtime [+-]n
  • n means modified precisely n days ago. This matches all files modified a week ago:
    find . -mtime 7

  • +n means modified at least n days ago. This matches all files older than a week:
    find . -mtime +7

  • -n means modified within the last n days. This matches all files older than a week:
    find . -mtime -7