Created
August 12, 2015 19:52
-
-
Save PauloMigAlmeida/1b38830b99f48095b9da to your computer and use it in GitHub Desktop.
Search Java class within a directory. It's particularly useful when dealing with Maven conflicts.
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
#!/bin/bash | |
# Usage ./find_class_directory.sh <folder> <class> | |
# Example: ./find_class_directory.sh WEB-INF/lib SignatureReader | |
TARGET_DIR=$1 | |
TARGET_CLASS=$2 | |
LIST_FILES=$(ls -1 $TARGET_DIR | grep -i -e ".*\.jar") | |
while read -r line; do | |
FOUND_CLASSES_IN_JAR=$(unzip -l $TARGET_DIR/$line | awk '{print $4}' | tail -n +4 | grep $TARGET_CLASS) | |
if [ -n "$FOUND_CLASSES_IN_JAR" ] | |
then | |
echo "Found $FOUND_CLASSES_IN_JAR in $line" | |
fi | |
done <<< "$LIST_FILES" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment