Solved

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

Posted on 2016-10-24
10
52 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
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.

747 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now