Exclude the process grep on ps ax output

Regularly I use ps ax | grep pattern to get information about a particular process, but in the oupout the grep process is shown, how to avoid this?

Simply encloses within square brackets the first letter or number of the pattern, for example:

If
$ ps ax | grep firefox

shows

28089 ?        S      0:00 /bin/sh /usr/lib/firefox-3.0.8/run-mozilla.sh /usr/lib/firefox-3.0.8/firefox
28103 ?        Sl    26:25 /usr/lib/firefox-3.0.8/firefox
28785 pts/5    S+     0:00 grep firefox
Then
ps ax | grep [f]irefox

would show

28089 ?        S      0:00 /bin/sh /usr/lib/firefox-3.0.8/run-mozilla.sh /usr/lib/firefox-3.0.8/firefox
28103 ?        Sl    26:27 /usr/lib/firefox-3.0.8/firefox
Also you can use

ps ax | grep pattern | grep -v pattern

Further reading

  • – man ps
  • – info grep

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.