bash 命令:在 jars 的文件系统中搜索类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3939134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
bash command: search for class in file system of jars
提问by markdsievers
I'm wanting to recursively search my maven repository (an n folder deep heirachy of jars) for a specific class inside an unknown jar.
我想递归搜索我的 maven 存储库(一个 n 文件夹深层次的 jars)以查找未知 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.
jar -tvf myJar.jar | grep ClassIWant.class 适用于已知的 jar,但我在管道/链接 bash 命令以实现递归搜索时遇到问题。
Any hints much appreciated.
任何提示非常感谢。
采纳答案by markdsievers
Post already exists. Solved here Find a jar file given the class name?Thanks for the alternatives.
帖子已经存在。在这里解决找到给定类名的 jar 文件?感谢您的选择。
回答by gawi
find -name \*.jar | xargs -n1 -iFILE sh -c "jar tvf FILE | sed -e s#^#FILE:#g" | grep classIWant\.class | cut -f1 -d:
回答by ghostdog74
Bash 4+
重击 4+
shopt -s globstar
for file in **/*.jar
do
jar -tvf "$file" | grep ....
done
<4++
<4++
find /path -type f -name "*.jar" | while read -r FILE
do
jar -tvf "$FILE" | grep ....
done

