Generally you use ps command to find out all running process. You may also pipe out ps command output via grep command to pickup desired output.
Basically you don't want display grep command as the process.
Let us run combination of ps and grep command to find out all perl processes:
$ ps aux | grep perl
Output:
vivek 4611 0.0 0.7 10044 6068 ? Ss 02:40 0:00 /usr/bin/perl apps/monitor/gwl.pl root 4853 0.0 0.7 10044 6068 ? Ss 02:40 0:00 /usr/bin/perl /usr/share/webmin/miniserv.pl /etc/webmin/miniserv.conf vivek 5166 0.0 0.0 2884 748 pts/0 R+ 03:06 0:00 grep perl
In above example you are getting the grep process itself. To ignore grep process from output, type any one of the following:
$ ps aux | grep perl | grep -v grep
OR
$ ps aux | grep '[p]erl'
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins

- My 10 UNIX Command Line Mistakes
- 25 PHP Security Best Practices For Sys Admins
- The Novice Guide To Buying A Linux Laptop
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
Facebook it - Tweet it - Print it -
We're here to help you make the most of sysadmin work. So, subscribe!


{ 11 comments… read them below or add one }
Also works when you’re grepping for something in the output of the history command.
Nice one. I am not going to use this – I really don’t mind the grep command appearing. Still, its clever.
This has been an annoyance of mine for awhile now. However, its a bit too syntactically taxing for the marginal gain.
Does anybody know how to set up an alias to accomplish the same goal?
Jerod,
alias not possible as passing args interpreted by shell at the time of creation. But something as follows should help out:
function pps(){ ps aux | grep "$@" | grep -v 'grep'; } pps perlVivek:
Thanks a lot. Added that function to my .bashrc and it works like a charm!
$ ps aux | grep ‘[p]erl’
can you explain how this work? regexp ?
Putting one letter inside square brackets won’t change the meaning of grep expression. However, it removes the grep command from the matched lines because the expression ‘[p]erl’ matches only ‘perl’, not ‘[p]erl’, which is how the grep command itself is now shown in the process list.
Thanks for ur wonderful suggestion in adding to .bashrc……… Good… keep it up
Thanks man! Good suggestion , I got fed up by looking the grep in process list (itself).
I use this function to view or grep all processes on my mac. For Linux you might have to change the switches on the ps command.
So using using pss command without arguments, you will get a full list of all processes.
if you use pss with a single argument, the function will grep all the processes and it will double space the output.
function pss () {
if [ -n "$1" ]
then
ps -ajx | grep -i “$1″ | grep -v “grep” | sed G
else
ps -ajx
fi
}
ps -C perl