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:

$ ps ax | grep firefox


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
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
The tutorials here on LibreByte are provided under a free software licence. if you like my work you should consider:
Buy a Hosting/VPS or Dedicated Server at MCKHost

Leave a Reply

Your email address will not be published.

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