Skip to main content
1 of 4
Stéphane Chazelas
  • 586.4k
  • 96
  • 1.1k
  • 1.7k

An alternative to using -depth is to -prune the directories that you're going to delete anyway to tell find not to bother trying to find files in them:

find . \( -name build -o -name obj -o -name '*.so' \) -prune -exec rm -rf {} + 

Also note that *.so needs to be quoted as otherwise it may be expanded by the shell to the list of .so files in the current directory.

Stéphane Chazelas
  • 586.4k
  • 96
  • 1.1k
  • 1.7k