Created
May 26, 2020 23:20
-
-
Save haranjackson/8f4a77cf0bfe82773b6256bf72523af0 to your computer and use it in GitHub Desktop.
Shell script for finding Python function name duplicates
This file contains 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
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