LoginSignup
28
20

More than 5 years have passed since last update.

grepしてもpsコマンドのヘッダ行を表示するいくつかの方法

Posted at
$ ps aux | grep hoge

ってやったときにgrepのヘッダ行がないと、どのカラムが何かわからないので不便です

調べてみたらいくつか方法がありました

  1. ps aux | head -1 && ps aux | grep hoge

  2. ps aux | grep -e hoge -e %MEM

2回コマンドを叩くことが苦じゃなければ、どのコマンドでフィルタすればいいんだっけ
って悩まないで済む、以下のような感じでもいいのかもしれません

$ ps aux | head -1
USER PID %CPU %MEM VSZ RSS TT STAT STARTED TIME COMMAND
$ ps aux | grep hoge
...
28
20
0

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
28
20