Skip to content

Recursively delete every file with a certain extension (safely) — by Radu Rădeanu on Ask Ubuntu

intermediateforumCC BY-SA (Stack Exchange; version depends on post date)

Uses find with -delete. The answer stresses running the same find command without -delete first to see what would go, and keeping -delete as the last argument, because in the wrong position it deletes everything.

Quick steps

  1. Preview: find . -name "*.bak" -type f
  2. Then delete: find . -name "*.bak" -type f -delete

Paraphrased from the source. Menus can differ by version, so check the original for full details.

Read the full thread on askubuntu.com

Source: Recursively delete every file with a certain extension (safely) by Radu Rădeanu on Ask Ubuntu. Licence: CC BY-SA (Stack Exchange; version depends on post date).

Source reviewed
2026-11-02
Link checked
Not yet
Tested hands-on
Not by Oddbyte.Me

finddeletecleanup

More in Community Answers (Stack Exchange)