Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save haranjackson/8f4a77cf0bfe82773b6256bf72523af0 to your computer and use it in GitHub Desktop.
Save haranjackson/8f4a77cf0bfe82773b6256bf72523af0 to your computer and use it in GitHub Desktop.
Shell script for finding Python function name duplicates
find . -not -path '*/\.*' -type f -name "*.py" | # find non-hidden python files
xargs egrep -o 'def [A-Za-z0-9_]{1,}' | # find function def lines
egrep -v 'def __[a-z]{1,}__' | # ignore __init__, __repr__,...
awk -F "def " '{print $NF}' | # take function names
sort | # sort list of function names
uniq -c | # count occurrences of each
sort # sort again by count
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment