Ada beberapa alasan potensial untuk ini.
1)
Anda menyuruhnya menghapus direktori saja ( -type d), dan direktori itu masih memiliki file di dalamnya.
2)
Direktori Anda hanya berisi direktori lain, sehingga -type dakan menangani masalah konten. Namun Anda menggunakan OS-X, yang sebagian besar didasarkan pada FreeBSD, dan FreeBSD findsecara default akan memproses direktori sebelum isinya.
Namun -depthada opsi untuk mengatasi masalah ini dengan mengatakan finduntuk memproses direktori setelah isinya.
find ~ -name __pycache__ -type d -ls -delete -depth
Masalah ini tidak ada di linux karena -deleteopsi secara implisit memungkinkan -depth.
FreeBSD man 1 find:
-depth Always true; same as the non-portable -d option. Cause find to
perform a depth-first traversal, i.e., directories are visited in
post-order and all entries in a directory will be acted on before
the directory itself. By default, find visits directories in
pre-order, i.e., before their contents. Note, the default is not
a breadth-first traversal.
GNU man 1 find:
-depth Process each directory's contents before the directory itself. The -delete
action also implies -depth.
find ~ -path '*/__pycache__*' -delete, atau mungkinfind ~ -path '*/__pycache__/*' -o -name __pycache__ -deleteaman.