Created
September 26, 2017 10:34
-
-
Save stainboy/187b51a856356efe9223abed3bc40c93 to your computer and use it in GitHub Desktop.
Find duplicated classes in WAR file
This file contains hidden or 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
#!/usr/bin/env bash | |
# set -ex | |
function process { | |
local jar=$1 | |
unzip -l $jar | grep .class | awk '{print $4" '$jar'"}' >> wtf.txt | |
} | |
export -f process | |
function findup { | |
local num=$1 | |
local class=$2 | |
echo "[$num] $class" >> final.log | |
cat wtf.txt | grep $class | awk '{print " "$2}' >> final.log | |
echo >> final.log | |
} | |
export -f findup | |
rm -f wtf.txt | |
ls *.jar | awk '{print "process "$1}' | bash | |
cat wtf.txt | awk '{print $1}' | sort | uniq -c | grep -v '1 ' | sort -r > dup.txt | |
echo "$(cat dup.txt | wc -l) duplicates found in the given war package!" > final.log | |
cat final.log | |
echo "Analyzing..." | |
cat dup.txt | awk '{print "findup "$1" "$2}' | bash | |
cat final.log |
Author
stainboy
commented
Sep 26, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment