Revision: 3098
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at June 4, 2007 05:58 by thebugslayer
Initial Code
#!/usr/bin/env groovy import java.util.jar.* //Usage check. if(args.size() <2){ println "usage: ${this.class.name} searchstr jarfile [jarfile]" println " jarfile can be a directory, which will include all jar files." return } //Collect args for jar files. searchstr = args[0] jarfiles = [] args[1..-1].each{ arg-> file = new File(arg) if(file.isDirectory()){ file.eachFileMatch(~/.*\.jar$/){ jarfiles.add(it) } }else{ jarfiles.add(file) } } //println binding.variables //Find and print the entry listing! jarfiles.each{ file-> jarfile = new JarFile(file) jarfile.entries().each{ entry-> if (entry.name =~ searchstr){ println "$entry.name : $file.canonicalPath" } } }
Initial URL
Initial Description
Eg: groovy findjar "Servlet" /opt/tomcat/lib
Initial Title
Search entry in jar files
Initial Tags
java
Initial Language
Groovy