Skip to content

Instantly share code, notes, and snippets.

@peter-stratton
Created January 16, 2015 21:48
Show Gist options
  • Save peter-stratton/c127d6df835290261027 to your computer and use it in GitHub Desktop.
Save peter-stratton/c127d6df835290261027 to your computer and use it in GitHub Desktop.
Python *.pyc and __pycache__ recursive cleanup
#!/bin/bash
echo
echo `find . -type f -iname \*.pyc -not -path "./.*"`
echo `find . -type d -name __pycache__ -not -path "./.*"`
echo
read -p "Delete these files (y/n)? " RESP
case "$RESP" in
y|Y ) find . -type f -iname \*.pyc -not -path "./.*" -delete && find . -type d -name __pycache__ -not -path "./.*" -delete;;
n|N ) echo "Exiting without deleting anything.";;
* ) echo "invalid";;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment