In my mind, this should find the symbol I am looking for. Instead it does not find the symbol. Where am I going wrong? I know the symbol exists in one of the .jar files.
1 ARRAY=(`find ${PWD} -name '*.jar'`);
2 SYMBOL=$1;
3 for i in ${ARRAY[@]};
4 do
5 JAR=`jar -tf $i`;
6 GREPED=`echo ${JAR} | grep -s ${SYMBOL} | tr -d ' '`;
7 if [ "${GREPED}" != "" ]; then
8 echo $GREPED
9 fi
7 done
Perhaps I am misunderstanding the jar command options?
Say I download the android SDK for fun and run a tool on it that says it cant find a given class com.android.email.mail.Flag. So I run the above script with:
$ ./script.sh Flag
This should printh out the output of the jar
command. If I wanted the jar file line 8 above would be
echo $i
.
The jar usage seems ok, but there are too many variables, arrays, pipes that could have been avoided.
The following should work for you:
for i in `find ${PWD} -name "*.jar"`; do
jar -tf $i | grep -qs $1 && echo $i
done
This would list the jar file(s) containing the symbol.