Skip to content

Instantly share code, notes, and snippets.

@sourcerebels
Created July 5, 2011 14:31
Show Gist options
  • Save sourcerebels/1064936 to your computer and use it in GitHub Desktop.
Save sourcerebels/1064936 to your computer and use it in GitHub Desktop.
Not very well optimized script for searching recursively with regular expresions in several jar files. TO IMPROVE
#!/bin/bash
function usage() {
echo "usage: findInJars <path> <regexp>"
exit 1
}
[ $# -ne 2 ] && usage
jar=$(which jar)
path=$1
class=$2
[ $? -ne 0 ] && echo "No jar executable found in your PATH"
find $path -name '*.jar' | while read jarFile; do
$jar tvf $jarFile | grep $class > /dev/null
if [ $? -eq 0 ]; then
echo "**********************************************************************************"
echo "Class $class found on jar $jarFile"
echo "**********************************************************************************"
$jar tvf $jarFile | grep $class
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment