Ubuntu Technical

Ubuntu technical problems and solutions reference, a modern cookbook.

Grep is grepping itself

I sometimes need to stop an application with the kill command, due to it being frozen, or simply being buggy. The command to kill requires me to know the PID of the process.

ps aux | grep name-of-the-application

There will be at least 2 outputs: One with the application we want to kill, and the other one with the actual grep process we are running to find the PID in the first place:

pre      18775  1.2  0.0  12524  1972 pts/3    S    20:17   0:00 
pre      19137  0.0  0.0   9136  1068 pts/3    S+   20:17   0:00 grep --color=auto application-name

In order exclude grep from the output result I have found the following command

ps aux | grep application name | grep -v grep

Compliment of this answer

Flattr this


5 responses to “Grep is grepping itself

  1. Tushar Kumar November 18, 2011 at 2:17 pm


  2. Archiboldian April 27, 2013 at 10:00 am

    Grep grep veeee grep grep.

  3. New Balance Discount September 12, 2014 at 8:05 am

    I have fun with, cause I found exactly what I used to be taking a
    look for. You’ve ended my four day long hunt! God Bless you man. Have a great day.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: