02/08/2023 12:47 | Category: python

Tags: linuxbashpythonpycache

removing pycache folders recursively

It gets annoying sometimes dealing with __pycache__/ and it's associated output files.

I found this great command on StackOverflow that I'd like to remember. This is for removing __pycache__/, .pyc, and .pyo files.

Checking for files that will be removed:

find . | grep -E "(/__pycache__$|\.pyc$|\.pyo$)"

Removing the files:

find . | grep -E "(/__pycache__$|\.pyc$|\.pyo$)" | xargs rm -rf