Skip to content

Instantly share code, notes, and snippets.

@Fizzadar
Last active January 9, 2016 21:08
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 Fizzadar/bb2e3ef394aec25d3045 to your computer and use it in GitHub Desktop.
Save Fizzadar/bb2e3ef394aec25d3045 to your computer and use it in GitHub Desktop.
Recursively removes pyc files with no matching py file in the current directory
#!/bin/sh
# PyClean
# Remove .pyc files with no matching py file
FILES=`find . -name "*.pyc"`
for PYC_FILE in $FILES; do
PY_FILE=${PYC_FILE/.pyc/.py}
if [ ! -f "$PY_FILE" ] || [ "$1" = "--all" ]; then
if [ "$1" = "--debug" ]; then
echo "Missing py: $PY_FILE"
else
echo "Removing: $PYC_FILE"
rm -f $PYC_FILE
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment