Last active
October 28, 2018 07:01
-
-
Save gMan1990/1ef4dda4f0490bc3bea4ef3d14399e32 to your computer and use it in GitHub Desktop.
递归列出jar文件内容便于查找Class
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
#!/bin/bash | |
# usage: bash this.sh path | |
# $1: path, parsed | |
jarList() { | |
path=$1 | |
if [ -d "$path" ]; then | |
cd "$path" || exit #https://github.com/koalaman/shellcheck/wiki/SC2045 | |
for sub in *; do | |
if [ "/" = "$1" ]; then | |
jarList "/$sub" | |
else | |
jarList "$1/$sub" | |
fi | |
done | |
elif [ -f "$path" ]; then | |
if [ "." != "${path%%_*}" ] && [ "jar" = "${path##*.}" ]; then | |
echo -e "\nJAR: $path" | |
jar -tf "$path" | |
fi | |
else | |
echo "type unimplement, file: [$path]" | |
return 1 | |
fi | |
} | |
path=$1 | |
if [ -d "$path" ]; then | |
path=$(cd "$path" && pwd) | |
dirname=$(dirname "$path") | |
basename=$(basename "$path") | |
if [ "/" = "$basename" ]; then | |
basename="" | |
fi | |
elif [ -f "$path" ]; then | |
dirname=$(cd "$(dirname "$path")" && pwd) | |
basename=$(basename "$path") | |
else | |
echo "type unimplement, file: [$path]" | |
exit 1 | |
fi | |
if [ "/" = "$dirname" ]; then | |
dirname="" | |
fi | |
jarList "$dirname/$basename" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment