Skip to content

Instantly share code, notes, and snippets.

@obabawale
Forked from luzfcb/clean_py.sh
Created February 13, 2022 07:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save obabawale/857786811a03a817aa35b109dff1944d to your computer and use it in GitHub Desktop.
Save obabawale/857786811a03a817aa35b109dff1944d to your computer and use it in GitHub Desktop.
Recursively removes all .pyc files and __pycache__ directories in the current directory
#!/bin/sh
# recursively removes all .pyc , .pyo files and __pycache__ directories in the current
# directory
find . | \
grep -E "(__pycache__|\.pyc$|\.pyo$)" | \
xargs rm -rf
# or, for copy-pasting:
# find . | grep -E "(__pycache__|\.pyc$|\.pyo$)" | xargs rm -rf
# or, create command named "rmpyc"
# alias rmpyc='find . | grep -E "(__pycache__|\.pyc$|\.pyo$)" | xargs rm -rf'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment