Solved

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

Posted on 2016-10-24
10
126 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 5

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 P.S.
Hanno P.S. 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This article will help you understand what HashTables are and how to use them in PowerShell.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

726 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