find. -name 0 -exec rm -fr {} \; -- Gerard Weatherby | Application Architect NMRbox | Department of Molecular Biology and Biophysics | UConn Health 263 Farmington Avenue, Farmington, CT 06030-6406 uchc.edu<http://uchc.edu> On Mar 26, 2021, 9:58 PM -0400, Peng Yu <pengyu...@gmail.com>, wrote: *** Attention: This is an external email. Use caution responding, opening attachments or clicking on links. ***
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