find string in .jar file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers find string in .jar file
# 1  
Old 07-06-2007
Question find string in .jar file

Hello,

I have a .jar file and am trying to figure out if it is possible to search for some text in all the files in it without extracting it.

I was able to do it using jar xf <filename>.jar and then using grep but want a one liner.

Thanks in advanceSmilie
# 2  
Old 07-06-2007
A JAR is actually a Zip file. So, the following should work:

unzip -p some.jar | grep 'string'
# 3  
Old 07-06-2007
Question tried but didnt work

Actually jar file contains .class files which can be read by javap -c command.

but I dont know how to put it all together

I am trying this command in the extracted directory (extracted using jar xf command)

Code:
find . -type "class" -exec javap -c | grep getDslamModem {} \;

but the output says :

find: incomplete statement
grep: can't open {}
grep: can't open ;


any ideas
# 4  
Old 07-06-2007
Rakeshou,
I do not fully understand your requirement, but see if this works for you:
Code:
for mFile in `find . -name "*.class"`
do
  javap -c $mFile | egrep 'getDslamModem'
done

# 5  
Old 07-06-2007
need to trim the extension from filename returned by find command

I tried your solution but it is saying

ERROR:Could not find <path to class files>

javap command doesnt need .class extension thats y it is saying cound not find.

so we need to trim .class extension

I am sure it will work if the .class extension is trimmed off.

Thankls
# 6  
Old 07-06-2007
Rakeshou,
Run the following:
Code:
for mFile in `find . -name "*.class"`
do
  echo "File = "$mFile
#######javap -c $mFile | egrep 'getDslamModem'
done

# 7  
Old 07-06-2007
displaying

ERROR:Could not find <path to class files>.class

for all the files it parses
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find string in file and find the all records by string

Hello I would like to get know how to do this: I got a big file (about 1GB) and I need to find a string (for instance by grep ) and then find all records in this file based on a string. Thanks for advice. Martin (12 Replies)
Discussion started by: mape
12 Replies

2. Shell Programming and Scripting

Find string in file and append new string after

Hi All, I'm trying to insert a string into a file at a specific location. I'd like to add a string after the parent::__construct(); in my file. <?php if (! defined('BASEPATH')) exit('No direct script access allowed'); class MY_Controller extends CI_Controller { function... (6 Replies)
Discussion started by: jjkilpatrick
6 Replies

3. Shell Programming and Scripting

find string and replace with string in other file

Dear all, I need your help, I have file like this: file1:23456 01910964830098775635 34567 01942809546554654323 67589 26546854368698023653 09778 58716868568576876878 08675 86178546154065406546 08573 54165843543054354305 . .file2: 23456 25 34567 26 67589 27 (2 Replies)
Discussion started by: attila
2 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. Shell Programming and Scripting

Find multiple string in one file using find command

Hi, I want find multiple string in one file using find coomand. And keeping it in one variable.grep is not working. (5 Replies)
Discussion started by: vivek1489
5 Replies

6. Linux

Find String in FileName and move the String to new File if not found

Hi all, I have a question.. Here is my requirement..I have 500 files in a path say /a/b/c I have some numbers in a file which are comma seperated...and I wanted to check if the numbers are present in the FileName in the path /a/b/c..if the number is there in the file that is fine..but if... (1 Reply)
Discussion started by: us_pokiri
1 Replies

7. 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

8. Shell Programming and Scripting

i want to know entered string ends with .jar

Hi all, I want to know whelther string entered ends with .jar. Can any one help please.. Thank U Naree (3 Replies)
Discussion started by: naree
3 Replies

9. UNIX for Dummies Questions & Answers

How to find a text in jar and zip files.??

Hi, I have classes dir, in that I have jar and zip files, I need to find "Param.class" is in which zip or jar file? (1 Reply)
Discussion started by: redlotus72
1 Replies
Login or Register to Ask a Question