best way to find and delete (may contains directories)

Peng Yu <[email protected]>
Newsgroups gmane.comp.gnu.findutils.bugs
Message-ID <CABrM6w=Of4i5zWLYrbMxSAomLoieLr3WXkGxvi48=sk8kZqOrg@mail.gmail.com>
Hi,

If just find is used, the following error will be printed. There are
many ways to solve this problem.

$ mkdir -p {x..z}/0/
$ touch {x..z}/0/1.txt
$ find -name 0 -delete
find: cannot delete ‘./z/0’: Directory not empty
find: cannot delete ‘./x/0’: Directory not empty
find: cannot delete ‘./y/0’: Directory not empty

Assuming no directories to be deleted are in other, I come up with
this. Is this the best way (in terms of
robustness/readability/performance) to solve this problem?

$ find -name 0 -printf '%p\0' | xargs -r -0 rm -rf

-- 
Regards,
Peng
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.