利用正则表达式使grep进程不输出自身


ps aux | grep redis
redis       1092  0.9  1.7 1638008 559216 ?      Ssl  Jul05 188:00 /usr/bin/redis-server 127.0.0.1:6379
root     3366704  0.0  0.0 112728  2308 pts/1    S+   18:37   0:00 grep --color=auto redis
ps aux | grep [r]edis
redis       1092  0.9  1.7 1638008 559216 ?      Ssl  Jul05 188:00 /usr/bin/redis-server 127.0.0.1:6379

ps aux | grep [r]edis 进程中,grep参数是--color=auto [r]edis. 和grep的正则匹配不相符,因此不会输出到结果.


Leave a Reply

Your email address will not be published.

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

%d bloggers like this: