Ubuntu technical problems and solutions reference, a modern cookbook.
Grep is grepping itself
November 17, 2011Posted by on
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