JarScan, scan all JAR files in all subfolders for specific class

后端 未结 8 2223
一个人的身影
一个人的身影 2020-12-29 13:03

We are seeing an older version of a class being used, although we had the latest one deploy. To scan all JAR files in all subfolders of an application server, how do we writ

8条回答
  •  再見小時候
    2020-12-29 13:26

    Something like:

    find . -name '*.jar' | while read jarfile; do if jar tf "$jarfile" | grep org/jboss/Main; then echo "$jarfile"; fi; done
    

    You can wrap that up like this:

    jarscan() {
      pattern=$(echo $1 | tr . /)
      find . -name '*.jar' | while read jarfile; do if jar tf "$jarfile" | grep "$pattern"; then echo "$jarfile"; fi; done
    }
    

    And then jarscan org.jboss.Main will search for that class in all jar files found under the current directory

提交回复
热议问题