We help IT Professionals succeed at work.
Get Started

Grep for a specific string

luser9999
luser9999 asked
on
566 Views
Last Modified: 2012-05-11
Hi,

I have many tomcat instances are running on Linux server and I would like to grep them based on a string called "catalina.base" here is one example


root     27180     1  0 Feb25 ?        00:02:10 /opt/java/jdk1.5.0_16//bin/java -Djava.util.logging.config.file=/opt/net/crowd-2.0.3/apache-tomcat/conf/logging.properties -Xms128m -Xmx256m -XX:MaxPermSize=256m -Dfile.encoding=UTF-8 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/opt/net/crowd-2.0.3/apache-tomcat/endorsed -classpath :/opt/net/crowd-2.0.3/apache-tomcat/bin/bootstrap.jar -Dcatalina.base=/opt/net/crowd-2.0.3/apache-tomcat -Dcatalina.home=/opt/net/crowd-2.0.3/apache-tomcat -Djava.io.tmpdir=/opt/net/crowd-2.0.3/apache-tomcat/temp org.apache.catalina.startup.Bootstrap start

So when i  " ps -ef | grep java"  --> will return all the instances of java and out of which I need only the string value "-Dcatalina.base="

to make it clear my search out put should be,

-Dcatalina.base=/opt/net/crowd-2.0.3/apache-tomcat
-Dcatalina.base=/opt/test/tomcat-2.0.3/apache-tomcat
-Dcatalina.base=/opt/test123/staging/apache-tomcat
-Dcatalina.base=/home/catalina/catalina-2.0/apache-tomcat

thanks

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2013
Top Expert 2013
Commented:
This problem has been solved!
Unlock 1 Answer and 12 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE