论坛首页 Java企业应用论坛

find class in which jar

浏览 1249 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2012-02-28  

#!/bin/ksh
#this script is used to find class in which jar file
if [ "$#" -le "1" ]; then
   echo "Usage: $0 class_name jar_path_1 [jar_path2]...[jar_pathn]"
   exit 1
fi
#class to be found
CLASS=$1

shift 1
for JAR in $*
do
    if [ -d ${JAR} ]
    then
        JARS=`find ${JAR} -name "*.jar"`
    else
        JARS=${JAR}
    fi

    FOUND=""
    for EACHJAR in ${JARS}
    do
        FOUND=$(jar tf ${EACHJAR}|grep ${CLASS})

 if [ "x${FOUND}" != "x" ]
        then
            echo "-----------------------------------"
            echo ${CLASS} was found in ${EACHJAR}
            echo ${FOUND}|tr " "  "\n"|grep -v .classPK
        fi
    done
done
exit 0

 

论坛首页 Java企业应用版

跳转论坛:
Global site tag (gtag.js) - Google Analytics