bash命令:在jar文件系统中搜索类

发布于 2024-09-28 01:54:55 字数 334 浏览 1 评论 0原文

我想递归地搜索我的 Maven 存储库(一个 n 个文件夹深层的 jar 文件),以查找未知 jar 中的特定类。

jar -tvf myJar.jar | jar -tvf myJar.jar | grep ClassIWant.class 对于已知的 jar 非常有用,但我在管道/链接 bash 命令以实现递归搜索时遇到问题。

非常感谢任何提示。

相关:BASH :: 从命令行查找存档中的文件

I'm wanting to recursively search my maven repository (an n folder deep heirachy of jars) for a specific class inside an unknown jar.

jar -tvf myJar.jar | grep ClassIWant.class works great for a known jar but I'm having problems piping/chaining bash commands to achieve a recursive search.

Any hints much appreciated.

Related: BASH :: find file in archive from command line

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小女人ら 2024-10-05 01:54:55
find -name \*.jar | xargs -n1 -iFILE sh -c "jar tvf FILE | sed -e s#^#FILE:#g" | grep classIWant\\.class | cut -f1 -d:
find -name \*.jar | xargs -n1 -iFILE sh -c "jar tvf FILE | sed -e s#^#FILE:#g" | grep classIWant\\.class | cut -f1 -d:
離人涙 2024-10-05 01:54:55

重击 4+

shopt -s globstar
for file in **/*.jar
do
  jar -tvf "$file" | grep ....
done

<4++

find /path -type f -name "*.jar" | while read -r FILE
do
     jar -tvf "$FILE" | grep ....
done

Bash 4+

shopt -s globstar
for file in **/*.jar
do
  jar -tvf "$file" | grep ....
done

<4++

find /path -type f -name "*.jar" | while read -r FILE
do
     jar -tvf "$FILE" | grep ....
done
北恋 2024-10-05 01:54:55

帖子已经存在。在这里解决查找给定类名的 jar 文件? 谢谢对于替代方案。

Post already exists. Solved here Find a jar file given the class name? Thanks for the alternatives.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文