Next: , Previous: , Up: Actions   [Contents][Index]

3.4 Delete Files

Action: -delete

Delete files or directories; true if removal succeeded. If the removal failed, an error message is issued.

The use of the ‘-delete’ action on the command line automatically turns on the ‘-depth’ option (see find Expressions). This can be surprising if you were previously just testing with ‘-print’, so it is usually best to remember to use ‘-depth’ explicitly.

If ‘-delete’ fails, find’s exit status will be nonzero (when it eventually exits).

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, and the return code of the ‘-delete’ action will be true.