How to search for a string in JAR files

后端 未结 10 1120
小蘑菇
小蘑菇 2020-12-12 14:57

My application is built on Java EE.

I have approximately 50 jars in this application.

Is it possible to search for a particular keyword (actually I want to s

10条回答
  •  执笔经年
    2020-12-12 15:28

    You can use zipgrep on Linux or OSX:

    zipgrep "BEGIN REQUEST" file.jar
    

    If you wish to search a number of jars, do

    find libdir -name "*.jar" -exec zipgrep "BEGIN REQUEST" '{}' \;
    

    where libdir is a directory containing all jars. The command will recursively search subdirectories too.

    For windows, you can download cygwin and install zipgrep under it: http://www.cygwin.com/

    Edit 1

    To view the name of the file that the expression was found you could do,

    find libdir -name "*.jar" | xargs -I{} sh -c 'echo searching in "{}"; zipgrep "BEGIN REQUEST" {}'
    

提交回复
热议问题