Register now and start sharing your code snippets.
-->
Find a text pattern in jar files
Shell Script (Bash) posted about 1 year ago by marko
Helpful when you need to find a class or package in some jar file recursively below the current directory. Still needs a test to see if the file found was a file or directory. Works case insensitively. Uses the unzip command because of it’s performance superiority in comparison to jar.
1 #!/bin/sh 2 for f in `find . -type f -name '*\.jar'` 3 do 4 unzip -l $f | grep -i $1 && echo "was found in $f" 5 done