Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    Nearly 7 million very small DHCP lease files consumed all the inodes. find -delete saved the day; removed about 6.5 million files in the same time as rm took to remove about 20 thousand. Commented Feb 27, 2018 at 18:50
  • There is a subtle and possibly sinister problem with all these answers. Find does a depth first search - including subdirectories. If ./cache contains subdirectories those contents will ALSO be removed, but as written, find will try to delete the directories BEFORE deleting the content. There are solutions here: 1. Add -depth if deletion of subdirectories is desired. and 2. Add -type f to avoid attempting sub-directory deletion. Another way to limit to the CURRENT directory only is to use -prune Commented Jul 25, 2020 at 17:49
  • @SteventheEasilyAmused -delete automatically turns on -prune. But skipping directories is a good idea: find won't delete non-empty directories, but it will signal an error. Commented Jul 25, 2020 at 19:38