LoginSignup
12
12

More than 5 years have passed since last update.

ps | grep hoge で grep 自身も grep されるのを防ぐ

Posted at

一見何を言ってるのか分からないタイトルだが、分かる人には分かると思いますw

$ ps aux | grep redis
quanon          48559   0.1  0.0  2469924   1600   ??  Ss    2:09PM   0:00.21 redis-server 127.0.0.1:6379
quanon          49197   0.0  0.0  2423356     24 s002  R+    2:12PM   0:00.00 grep --color=auto --exclude-dir=.bzr --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn redis

うざい。

$ ps aux | grep -v grep | grep redis
quanon          48559   0.1  0.0  2469924   1608   ??  Ss    2:09PM   0:00.30 redis-server 127.0.0.1:6379

-v オプションで grep を grep しないようにしたけど、長くなってしまった。

$ alias ps\?="ps aux | grep -v grep | grep"
$ ps? redis
quanon          48559   0.1  0.0  2469924   1608   ??  Ss    2:09PM   0:00.34 redis-server 127.0.0.1:6379

これでよしとする。

12
12
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
12