find: Delete Files

 
 3.4 Delete Files
 ================
 
  -- Action: -delete
      Delete files or directories; true if removal succeeded.  If the
      removal failed, an error message is issued and ‘find’'s exit status
      will be nonzero (when it eventually exits).
 
           Warning: Don't forget that ‘find’ evaluates the command line
           as an expression, so putting ‘-delete’ first will make ‘find’
           try to delete everything below the starting points you
           specified.
 
      The use of the ‘-delete’ action on the command line automatically
      turns on the ‘-depth’ option.  As in turn ‘-depth’ makes ‘-prune’
      ineffective, the ‘-delete’ action cannot usefully be combined with
      ‘-prune’.
 
      Often, the user might want to test a ‘find’ command line with
      ‘-print’ prior to adding ‘-delete’ for the actual removal run.  To
      avoid surprising results, it is usually best to remember to use
      ‘-depth’ explicitly during those earlier test runs.
 
      See ⇒Cleaning Up for a deeper discussion about good use
      cases of the ‘-delete’ action and those with surprising results.
 
      The ‘-delete’ action will fail to remove a directory unless it is
      empty.
 
      Together with the ‘-ignore_readdir_race’ option, ‘find’ will ignore
      errors of the ‘-delete’ action in the case the file has disappeared
      since the parent directory was read: it will not output an error
      diagnostic, not change the exit code to nonzero, and the return
      code of the ‘-delete’ action will be true.