Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grep for process 2

Status
Not open for further replies.

kasparov

Programmer
Feb 13, 2002
203
GB
I remember reading an answer to this question a few years ago - I've searched but can't find it. If I want to grep the process list for a process I've just run I always get my grep process in the output. I can remove this by piping to grep -v grep but I know there's a more elegant solution, using [grep] if I remember rightly. Can anyone remind me what the answer is?

example:
Code:
# sleep 500 &
24851
# ps -ef | grep sleep
    root 24855 24803  0 13:18:08 pts/9    0:00 grep sleep
    root 24851 24803  0 13:18:04 pts/9    0:00 sleep 500
#
# ps -ef | grep sleep | grep -v grep
    root 24851 24803  0 13:18:04 pts/9    0:00 sleep 500
#

Cheers, Chris
 
Code:
ps -ef | grep [s]leep
Thanks to p5wizard, if I remember correctly, who told me.

Ceci n'est pas une signature
Columb Healy
 
Thanks columb - I knew there were square brackets somewhere ...

Shame I can't give p5wizard a star too!
 
Shameless, that's what it is ;-) !

I want to be good, is that not enough?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top