grep进程时忽略自身

我们在通过进程ID查找进程时,通过如下命令:

ps -ef | grep 2112

 来查找,但是这通常不能如愿:

[root@Linux-dtowen ~]# ps -ef | grep 2132
dtowen    2132  2118  0 22:51 ?        00:00:00 /usr/libexec/ibus-engine-pinyin --ibus
root      2247  2192  0 23:01 pts/1    00:00:00 grep 2132

 2247明显就不是我们想要的,那么能不能把2247这个进程给去掉呢?答案是可以的。如下:

[root@Linux-dtowen ~]# ps -ef | grep 2132 | grep -v grep
dtowen    2132  2118  0 22:51 ?        00:00:00 /usr/libexec/ibus-engine-pinyin --ibus

猜你喜欢

转载自yangtze21.iteye.com/blog/2197540