このページの2つのバージョン間の差分を表示します。
両方とも前のリビジョン前のリビジョン次のリビジョン | 前のリビジョン | ||
02_freebsd:80_unixコマンド:ps_grep [2015/08/25 05:17] – 50_dialy:2015:08:25 renamed to 02_freebsd:80_unixコマンド:ps_grep matsui | 02_freebsd:80_unixコマンド:ps_grep [2015/08/25 05:19] (現在) – matsui | ||
---|---|---|---|
行 1: | 行 1: | ||
+ | ====== ps でgrepについて ====== | ||
+ | |||
+ | 新しい発見をしたのでメモ | ||
+ | |||
+ | 今までは、ps でgrep を行う時に、grep自身を「grep -v grep」で省いてたが、一発で表示する方法 | ||
+ | |||
+ | ===== 方法 ===== | ||
+ | |||
+ | grepする文字の1文字目を[]で囲むことで、「grep -v grep」しなくてもgrep自身を省く事ができます。 | ||
+ | |||
+ | < | ||
+ | # ps auxw | grep [h]ttp | ||
+ | root | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | </ | ||
+ | |||
+ | ===== 旧方法 ===== | ||
+ | |||
+ | grep自身が表示されるので、正確なデータを取得する場合は、「grep -v grep」を入れる必要がある。 | ||
+ | |||
+ | < | ||
+ | # ps auxw | grep http | ||
+ | root | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | apache | ||
+ | root | ||
+ | </ | ||
+ | |||
+ | |||
+ | {{tag> |