Exclude grep from process list

Posted by
Facebooktwitterredditpinterestlinkedintumblr

By default if you grep the word getty in process list (using ps command), shell returns the output below.

[email protected]:~$ ps ax | grep getty
 1019 tty4     Ss+    0:00 /sbin/getty -8 38400 tty4
 1026 tty5     Ss+    0:00 /sbin/getty -8 38400 tty5
 1031 tty2     Ss+    0:00 /sbin/getty -8 38400 tty2
 1032 tty3     Ss+    0:00 /sbin/getty -8 38400 tty3
 1036 tty6     Ss+    0:00 /sbin/getty -8 38400 tty6
 3153 tty1     Ss+    0:00 /sbin/getty -8 38400 tty1
 3421 pts/1    S+     0:00 grep --color=auto getty

To exclude grep from process list use the following command:

[email protected]:~$ ps ax | grep -v grep | grep getty
 1019 tty4     Ss+    0:00 /sbin/getty -8 38400 tty4
 1026 tty5     Ss+    0:00 /sbin/getty -8 38400 tty5
 1031 tty2     Ss+    0:00 /sbin/getty -8 38400 tty2
 1032 tty3     Ss+    0:00 /sbin/getty -8 38400 tty3
 1036 tty6     Ss+    0:00 /sbin/getty -8 38400 tty6
 3153 tty1     Ss+    0:00 /sbin/getty -8 38400 tty1
[email protected]:~$ ps ax | grep "[g]etty"
 1019 tty4     Ss+    0:00 /sbin/getty -8 38400 tty4
 1026 tty5     Ss+    0:00 /sbin/getty -8 38400 tty5
 1031 tty2     Ss+    0:00 /sbin/getty -8 38400 tty2
 1032 tty3     Ss+    0:00 /sbin/getty -8 38400 tty3
 1036 tty6     Ss+    0:00 /sbin/getty -8 38400 tty6
 3153 tty1     Ss+    0:00 /sbin/getty -8 38400 tty1

Leave a Reply

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

*