Last active
July 11, 2017 19:33
-
-
Save abdul/ee3236e597a05acf534fb523c8ce2ca9 to your computer and use it in GitHub Desktop.
Remove .pyc files only when corresponding (source) .py doesn't exist.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| set -e | |
| pycfiles=($(find . -name "*.pyc")) | |
| for i in "${pycfiles[@]}"; do | |
| pyfile="${i%.pyc}.py" | |
| if [ ! -e "$pyfile" ]; then | |
| echo "Removing "$i" because source file ("$pyfile") doesn't exist." | |
| rm $i | |
| fi | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment