如何在 JAR 文件中搜索字符串 [英] How to search for a string in JAR files

查看:32
本文介绍了如何在 JAR 文件中搜索字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序是基于 Java EE 构建的.

My application is built on Java EE.

我在这个应用程序中有大约 50 个 jar.

I have approximately 50 jars in this application.

是否可以搜索特定的关键字(实际上我想搜索关键字BEGIN REQUEST)?

Is it possible to search for a particular keyword (actually I want to search for a keyword BEGIN REQUEST)?

推荐答案

您可以在 Linux 或 OSX 上使用 zipgrep:

You can use zipgrep on Linux or OSX:

zipgrep "BEGIN REQUEST" file.jar

如果您想搜索多个 jar,请执行

If you wish to search a number of jars, do

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

其中 libdir 是包含所有 jar 的目录.该命令也会递归搜索子目录.

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

对于windows,可以下载cygwin并在其下安装zipgrep:http://www.cygwin.com/

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

编辑 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" {}'

这篇关于如何在 JAR 文件中搜索字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆