Solved

looking for unix program to search some keywords in side EAR WAR and JAR files

Posted on 2016-10-24
10
94 Views
Last Modified: 2016-11-09
Hi,

I am looking for unix program to search some keywords(say "hello", "world" etc) in side EAR file (say xyz.EAR) which has a  WAR file(say abc.war) and has JAR files(like def.jar, ghi.jar).

I have installed cygwin and MobaXTerm already. Please advise
0
Comment
Question by:gudii9
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 4

Accepted Solution

by:
Abhimanyu Suri earned 250 total points
ID: 41857767
Here is an example of egrep

/home/TEST>ls -ltrR
.:
total 20
-rw-r--r-- 1 oracle oinstall    6 Oct 24 18:03 abc
drwxr-xr-x 3 oracle oinstall 8192 Oct 24 18:05 TEST1

./TEST1:
total 28
-rw-r--r-- 1 oracle oinstall    6 Oct 24 18:04 def
-rw-r--r-- 1 oracle oinstall    6 Oct 24 18:04 ghi
-rw-r--r-- 1 oracle oinstall    6 Oct 24 18:05 klm
drwxr-xr-x 2 oracle oinstall 8192 Oct 24 18:06 TEST2

./TEST1/TEST2:
total 4
-rw-r--r-- 1 oracle oinstall 7 Oct 24 18:06 nop


/home/TEST/TEST1/TEST2>cat nop

hello
/home/TEST/TEST1/TEST2>cd ..
/home/TEST/TEST1>ls -ltrh
total 28K
-rw-r--r-- 1 oracle oinstall    6 Oct 24 18:04 def
-rw-r--r-- 1 oracle oinstall    6 Oct 24 18:04 ghi
-rw-r--r-- 1 oracle oinstall    6 Oct 24 18:05 klm
drwxr-xr-x 2 oracle oinstall 8.0K Oct 24 18:06 TEST2
/home/TEST/TEST1>cat def
hello
/home/TEST/TEST1>cat ghi
world
/home/TEST/TEST1>cat klm
world
/home/TEST/TEST1>cd ..
/home/TEST>ls -ltr
total 20
-rw-r--r-- 1 oracle oinstall    6 Oct 24 18:03 abc
drwxr-xr-x 3 oracle oinstall 8192 Oct 24 18:05 TEST1
/home/TEST>cat abc
hello
/home/TEST>
/home/TEST>

/home/TEST>egrep -iR "hello|world" ./*
./abc:hello
./TEST1/TEST2/nop:hello
./TEST1/def:hello
./TEST1/ghi:world
./TEST1/klm:world
/home/TEST>
0
 
LVL 16

Assisted Solution

by:Hanno Schröder
Hanno Schröder earned 125 total points
ID: 41858417
a) "strings" will display all readable strings in any give file
strings def | grep -i world

Open in new window

b) an WAR or JAR is nothing else but a (slightly modified) tar archive
tar xvf - def.jar | grep -i hello

Open in new window

Does this help?
0
 
LVL 7

Author Comment

by:gudii9
ID: 41858623
any sample shell script for this?
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 125 total points
ID: 41858632
jars are (almost always) collections of zip encoded files in an archive. As such, strings like 'hello' may not be detectable, even if they are in one of the files compressed in the archive. Of course nesting jars raises the bar even higher
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41858680
If the file in the jars are compressed (in which way ever) the only way
would be to unpack the archives (hierarchally where needed) and
scan the resulting diretory tree afterwards
To give you some idea: Scan all files in current directory tree, try something like
cd <top-level-directory>
strings `find * -type f` | grep -i hello 

Open in new window

0
 
LVL 7

Author Comment

by:gudii9
ID: 41858686
how to search multiple words about 100 same time and generate some text report? any sample shell script to this. if i search hello it should not find helloall as well.  Needs to be correct match
0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41858731
Use grep in the right way no NOT match helloxyz, only hello as a single word
Something like:
grep -i '[ ^]hello[$ ]'

Open in new window

Read how to use (and compose) regular expresiions for grep to accomplish this.

To put all this into a file:
strings `find * -type f` | grep -i hello > report.txt 2>&1 

Open in new window

0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41858796
Using Perl regex (depending on what version of grep you have) is easier

grep -iP '\bhello\b'

Open in new window

0
 
LVL 16

Expert Comment

by:Hanno Schröder
ID: 41858836
... as you say "depending on grep version".
Your man page(s) for grep should shed light on this.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41880885
Sorry - how does the 'Accepted Solution' answer the question in any way?
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Set OWA language and time zone in Exchange for individuals, all users or per database.
A brief introduction to what I consider to be the best editor for PowerShell.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question