Skip to content

Instantly share code, notes, and snippets.

@thedch
Created January 25, 2020 19:04
Show Gist options
  • Save thedch/e8637a0f9b3ff0fce47088b3ce2e8262 to your computer and use it in GitHub Desktop.
Save thedch/e8637a0f9b3ff0fce47088b3ce2e8262 to your computer and use it in GitHub Desktop.
A bunch of greps strung together to find unused classes in Python. May have bugs.
#!/bin/bash
# there's probably (definitely?) a better way to do this, but it seems to work.
classes=$(grep -oEh "^class \w+[\(:]" * | cut -c 7- | sed 's/.\{1\}$//')
for c in $classes ; do
grep $c * | grep -vq "class" || echo $c
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment