Hey Guys,
I need to search inside all the jar files of my directory for a specific string. Can anyone guide me as to how i can do it. I need this urgently please. More specifically i need to search for a class file name in the jar files.
Thanks in advance
use the -a option of grep:
grep -a text_to_search file.jar
a bit of advice: don't expect people here to give you urgent replies. an urgency on your part does not create urgency for others.
Advice taken More specifically i am looking for this.
jar file contains a list of class files. I want to check against the name of one of the class files. I want to do this recursively. The approach that i am looking at is somewhat on the lines of - extracting the jar file, and then checking the extracted files to see if any of them contain the required string as a part of their class name. Does that make sense?
or if there is a better approach, please let me know.
This is what i have tried.
#!/bin/bash
for i in *.jar ; do
jar xf $i /* This will extract the jar file */
find -name "SearchString" . /*This will search for the search string */
done
I know i am far from done.. So i need help on this.
If you are just doing a filename check, a "jar tf" would be more suitable as it outputs all files inside a jar recursively - then you can easily grep, or do whatever with the file list.