2

I'm trying sudo find . -type d -name '__pycache__' -delete as found here https://github.com/python-mode/python-mode#how-to-install on the trouble shooting page of python-mode. The terminal returns: find: cannot delete 'path' : directory not empty.

Is there a way to work around this. It surprises me this doesn't work as it is literally in the python-mode README.

I'm on Fedora 29 workstation.

0

2 Answers 2

1

You can use the exec option of find to use an external command to handle the delete such as rm -rf.

Example:

sudo find . -type d -name '__pycache__' -exec rm -rf "{}" \;

Note: the {} is a placeholder for the file path and \; ends the exec command. See man 1 find for more details

0

you could do

sudo find . -type d -name '__pycache__' -exec rm -rf {} \;

or work with xargs

sudo find . -type d -name 'test' | sudo xargs rm -rf
1
  • This will work with xargs as long as you do not have directories with a new-line character in them. Let's say i can create "/home/user/something\n/bin\nanything" If i know that you will run this script it will delete /bin. Congratulations you have killed the system.
    – v010dya
    Commented Nov 23, 2021 at 18:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .