The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > OS Specific Forums > SUN Solaris
Google UNIX.COM


SUN Solaris The Solaris Operating System, usually known simply as Solaris, is a free Unix-based operating system introduced by Sun Microsystems .

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
search excat string in another string (grep "fails") bora99 UNIX for Dummies Questions & Answers 0 06-05-2008 03:41 AM
Grep string and next line karthikn7974 Shell Programming and Scripting 7 05-23-2008 02:06 AM
grep for a search string raga UNIX for Dummies Questions & Answers 11 03-12-2008 04:38 AM
grep string & a few lines after ashterix Shell Programming and Scripting 3 03-03-2008 12:48 AM
grep a string in a line using sed viadisky UNIX for Dummies Questions & Answers 4 02-06-2007 02:03 AM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-05-2007
Registered User
 

Join Date: Oct 2004
Posts: 69
Stumble this Post!
ps -ef |grep <string>

I'm sure the solution to my problem is a simple one, but I just can't figure this one out.

I'm doing a ps -ef and I want to grep for a string, but I do not want the grep process to appear in the results.

Does anyone know what switch I can use to accomplish the above?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 12-05-2007
Neo's Avatar
Neo Neo is offline
Administrator
 

Join Date: Sep 2000
Location: Asia Pacific
Posts: 4,292
Stumble this Post!
Code:
ps -ef | grep stuff | grep -v grep
Reply With Quote
  #3 (permalink)  
Old 12-05-2007
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,002
Stumble this Post!
or
Code:
ps -ef | grep [s]tring
Reply With Quote
  #4 (permalink)  
Old 12-05-2007
Registered User
 

Join Date: Dec 2007
Location: Paris
Posts: 354
Stumble this Post!
or
Code:
pgrep string
Reply With Quote
  #5 (permalink)  
Old 12-06-2007
Registered User
 

Join Date: Oct 2007
Location: Wellington, New Zealand
Posts: 30
Stumble this Post!
pgrep greps through running processes, but by default only returns the process id's.

Code:
pgrep -fl string
will give you a bit more detail.
Reply With Quote
  #6 (permalink)  
Old 12-06-2007
Smiling Dragon's Avatar
Disorganised User
 
Join Date: Nov 2007
Location: New Zealand
Posts: 709
Stumble this Post!
Quote:
Originally Posted by Neo View Post
Code:
ps -ef | grep stuff | grep -v grep
If you do that the other way round (ie grep out "grep" first) you get a usable exit code
Reply With Quote
  #7 (permalink)  
Old 12-06-2007
Registered User
 

Join Date: Oct 2007
Posts: 153
Stumble this Post!
It all depends on what you're looking for. If you're just looking for the command name:

Code:
ps -wwaAco pid,command | awk '$2~P{print $1}' P="stuff"
Of course, if you need to search through the full paths and command args, you'll need to remove the "c" flag (and then grep out the grep).
Reply With Quote
Google The UNIX and Linux Forums
Reply

Tags
linux

Thread Tools
Display Modes




All times are GMT -7. The time now is 10:51 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0