I want to delete all .pyc and .pyo files recursively but exclude a certain directory. I just ran into some limitation where find cannot delete when ignoring. I tried piping the result to xargs rm
but that fails, too.
find . -not \( -path somedir -prune \) -name '*.py[co]' -exec rm '{}' \;
with error:
find: The -delete action atomatically turns on -depth, but -prune does nothing when -depth is in effect. If you want to carry on anyway, just explicitly use the -depth option.
This also fails:
find . -type f -not -path 'somdir/*' -name '*.py[co]' -print0 | xargs -0 rm
Versions:
- OS: Ubuntu 14.04 LTS
- find version 4.4.2
-delete
in yourfind
invocation…