shell 批量搜索jar文件内容

遍历批量搜索jar文件,找到含有关键字的jar文件

搜索含有ServerStatusHelper

cat class_search.sh
#搜索脚本
cd /app/IBM/WebSphere
find . -name "*.jar" -type f > /tmp/jar.txt
for item in $(cat /tmp/jar.txt)
do 
    unzip -l $item |grep "ServerStatusHelper"
    if [ $? -eq 0 ]; then
       echo "the jar file is $item"
    fi
done
#搜索结果
     1483  11-07-2014 11:34   com/ibm/ws/security/config/ServerStatusHelper.class
the jar file is ./AppServer/runtimes/com.ibm.ws.ejb.thinclient_8.5.0.jar
     1483  11-07-2014 11:34   com/ibm/ws/security/config/ServerStatusHelper.class
the jar file is ./AppServer/runtimes/com.ibm.ws.webservices.thinclient_8.5.0.jar
     1483  11-07-2014 11:34   com/ibm/ws/security/config/ServerStatusHelper.class
the jar file is ./AppServer/runtimes/com.ibm.jaxws.thinclient_8.5.0.jar
     1483  11-07-2014 11:34   com/ibm/ws/security/config/ServerStatusHelper.class
the jar file is ./AppServer/runtimes/com.ibm.ws.admin.client_8.5.0.jar
     1483  11-07-2014 11:34   com/ibm/ws/security/config/ServerStatusHelper.class
the jar file is ./AppServer/plugins/com.ibm.ws.runtime.jar
     1483  11-07-2014 11:34   com/ibm/ws/security/config/ServerStatusHelper.class
the jar file is ./AppClient/plugins/com.ibm.ws.runtime.client.jar

你可能感兴趣的:(shell)