Skip to content

Instantly share code, notes, and snippets.

@hbsdev
Forked from joelverhagen/clean_py.sh
Last active August 8, 2024 14:21
Show Gist options
  • Save hbsdev/a17deea814bc10197285 to your computer and use it in GitHub Desktop.
Save hbsdev/a17deea814bc10197285 to your computer and use it in GitHub Desktop.
Recursively remove all .pyc files and __pycache__ directories in the current directory.
#!/bin/sh
# recursively removes all .pyc files and __pycache__ directories in the current
# directory
find . | grep -E "(__pycache__|\.pyc$)" | xargs rm -rf
@hodunov
Copy link

hodunov commented Sep 5, 2023

thanks 🙂

@littlebeeper
Copy link

littlebeeper commented Sep 8, 2023

You need to escape $ if you intend to use this command in Makefile
find ./package | grep -E "(__pycache__|\.pyc$$)" | xargs rm -rf

@bezborodow
Copy link

bezborodow commented Feb 8, 2024

There is no need to invoke grep, xargs, or rm. Try instead:

find . -regex '^.*\(__pycache__\|\.py[co]\)$' -delete

@NanthagopalEswaran
Copy link

To make it simple, I made it as a file manager extension. you can go to folder and right click and select Remove PyCaches option.

NO NEED OF ANY ARGS TO PASS.
EASY TO USE

Tool link (https://github.com/python-dev-tools/pycache-cleaner)

@littlebeeper
Copy link

littlebeeper commented Apr 2, 2024

To make it simple, I made it as a file manager extension. you can go to folder and right click and select Remove PyCaches option.

NO NEED OF ANY ARGS TO PASS.
EASY TO USE

Tool link (https://github.com/python-dev-tools/pycache-cleaner)

This repo looks very suspicious. Why is there an executable in your repo @NanthagopalEswaran?

@NanthagopalEswaran
Copy link

@littlebeeper, That's the installer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment