Search inside a Jar file..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Search inside a Jar file..
# 1  
Old 12-26-2008
Search inside a Jar file..

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 :-)
# 2  
Old 12-26-2008
use the -a option of grep:
Code:
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.
# 3  
Old 12-26-2008
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.
# 4  
Old 12-26-2008
This is what i have tried.

Code:
#!/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.
# 5  
Old 12-30-2008
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Getting the version from jar file

Hi, I am trying to retrieve the "Implementation version" from one of the .jar file The command which tried is as below. find /usr/local/platform -name "platform.jar" -exec zipgrep "Implementation-Version:" '{}' \;|awk -F ': ' '{print $2}'I am able to get the version as below 2.9.0-29But... (2 Replies)
Discussion started by: nextStep
2 Replies

2. UNIX for Beginners Questions & Answers

Search a string inside a pattern matched block of a file

How to grep for searching a string within a begin and end pattern of a file. Sent from my Redmi 3S using Tapatalk (8 Replies)
Discussion started by: Baishali
8 Replies

3. Shell Programming and Scripting

Search inside a file, PERL

HEllo!! I need a script in perl that see inside a file(file.txt) that has only one row. The row contains only this text: logs_yearly = 20120628113345 I want that the script does this: "Search in the file, if the date 20120628 is actual date" Thank you!! ---------- Post... (4 Replies)
Discussion started by: super_sun
4 Replies

4. Shell Programming and Scripting

Want to write all the jar name in single with delimiter ":" in beween the jar name

Hi All, I am having 7 jar files in a dir. abc like listed below bash-3.00$ cd abc bash-3.00$ ls 123.jar 23wdawd.jar dfsa23.jar dsa.jar wew234.jar adsd234234.jar dfsda423.jarNow i want to assign all this jar files to a variable in the below format ... (6 Replies)
Discussion started by: natraj005
6 Replies

5. UNIX for Advanced & Expert Users

how to read a file inside jar

how to read the text file inside the jar without extracting jar. (3 Replies)
Discussion started by: karthikn
3 Replies

6. UNIX for Dummies Questions & Answers

down in JAR file

Hello sir, I have created a jar file having some code in java.What it does is that it calls a shell code (a.sh) which is in the same directory. Now my requirement is that I want to jar the a.sh also along with the other files and want to call the a.sh which is now inside the jar file and not... (1 Reply)
Discussion started by: nsharath
1 Replies

7. UNIX for Dummies Questions & Answers

Search and Parse string from inside a File

Hello, I barely know the basics, but I am very determined to learn. I want to parse a few characters from each row, use that string to search another file and display the line number where I found the value in the file. I don't know if this can all be done on the command line, so I am creating a... (2 Replies)
Discussion started by: SSims
2 Replies

8. Shell Programming and Scripting

How to search a pattern inside a zipped file ie (.gz file) with out unzipping it

How to search a pattern inside a zipped file ie (.gz file) with out unzipping it? using grep command.. Bit urgent.. pls..help me (2 Replies)
Discussion started by: senraj01
2 Replies

9. Shell Programming and Scripting

Jar File Search!

Hi vgersh99, Iam sorry for that. In future, I will start new threads for different topics. Assuming that we don't know what the name of the jar file, we are searching for is, do we have any way, of finding a string or a file in it. Is there any Unix command for it? thanks. (2 Replies)
Discussion started by: pjanakir
2 Replies
Login or Register to Ask a Question