forked from rakeshcusat/Code4Reference
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjarscan.sh
executable file
·49 lines (43 loc) · 895 Bytes
/
jarscan.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/bin/bash
#This script is to search jar file for java class file.
USAGE="Usage: `basename $0` [-hw] <class-name> <dir-path>
-h For help
-w exact class name match
e.g :
./`basename $0` -w Activity ./android-sdk-linux
"
#parse command line options
while getopts hw OPT;do
case "$OPT" in
h)
echo -e "$USAGE"
exit 0
;;
w)
specific=1
;;
\?)
#getopts issues an error
echo -e "$USAGE" >&2
exit 1
;;
esac
done
shift `expr $OPTIND - 1`
#echo "print 1 : $1"
if [ "$specific" -eq 1 ]; then
pattern="/$1\\.class"
else
pattern=$1
fi
shift
#echo "pattern : $pattern"
for I in $(find $* -type f -name "*.jar")
do
match=`jar -tf $I | grep $pattern`
if [ ! -z "$match" ]
then
echo "Found in: $I"
echo "$match"
fi
done