Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 552
  • Last Modified:

using ps with grep shows grep as a process

Hi there,

I am executing the following command:
ps -auxww | grep <process_name>
and after I run this it shows the process name but it also shows grep as a process and I don't want that. How could I prevent showing grep as a process
Thanks.
0
nikolap
Asked:
nikolap
1 Solution
 
liddlerCommented:
ps -auxww | grep <process_name> |grep -v grep
0
 
glassdCommented:
Neater solution:
ps -auxww | grep [p]rocess_name

The grep process will have embedded square brackets which the grep will fail to match.
0
 
prady_21Commented:
ps -auxww | grep ps

0
 
bkrahmerCommented:
You didn't mention what platform you are on.  Some really nice ones (Solaris!) give you things like pgrep.  Does all the nasty for you.

brian
0
 
glassdCommented:
pgrep is fine if you are running a late version of solaris and want the PID. If you are running a multiplatform environment, possibly with older versions of solaris, or want some other info (eg PPID) then you are often better sticking to the more generic forms in scripts. You can get a job anywhere then!!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now