Created
July 19, 2021 13:57
-
-
Save peeyushsrj/932f9710d2e695d11f8c4989f8e8f3d9 to your computer and use it in GitHub Desktop.
Print unused packages in python scripts
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
# bash pyunused.sh filename.py | |
s=$(cat $1 | grep import | grep as | awk '{print $4}') | |
t=$(cat $1 | grep import | grep -v as | awk '{print $2}') | |
echo "Following unused packages" | |
echo "-------------------------" | |
for el in $s; do | |
count=$(cat $1 | grep $el | wc -l) | |
if (( ${count} == 1 )); then | |
echo $el | |
fi | |
done | |
for el in $t; do | |
count=$(cat $1 | grep $el | wc -l) | |
if (( ${count} == 1 )); then | |
echo $el | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment