Recursively delete every file with a certain extension (safely) — by Radu Rădeanu on Ask Ubuntu
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
- Preview: find . -name "*.bak" -type f
- Then delete: find . -name "*.bak" -type f -delete
Paraphrased from the source. Menus can differ by version, so check the original for full details.
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