Tony
Jan 8, 2023

--

Excellent question, I think technically "-delete" will have better performance since no need to spawn an external process for deleting. However, you need to be a little care with "-delete", make sure to use it after "-name", otherwise it will delete the specified entire file tree. Also note that "-delete" will not delete directories if they are not empty.

For example:

$ find . -type d -name ".testfolder" -delete

find: cannot delete ‘./.testfolder’: Directory not empty

--

--

Tony
Tony

Responses (1)