この文書の現在のバージョンと選択したバージョンの差分を表示します。
両方とも前のリビジョン 前のリビジョン | |||
02_freebsd:80_unixコマンド:ps_grep [2015/08/25 14:18] matsui |
02_freebsd:80_unixコマンド:ps_grep [2015/08/25 14:19] (現在) matsui |
||
---|---|---|---|
ライン 1: | ライン 1: | ||
+ | ====== ps でgrepについて ====== | ||
+ | |||
+ | 新しい発見をしたのでメモ | ||
+ | |||
+ | 今までは、ps でgrep を行う時に、grep自身を「grep -v grep」で省いてたが、一発で表示する方法 | ||
+ | |||
+ | ===== 方法 ===== | ||
+ | |||
+ | grepする文字の1文字目を[]で囲むことで、「grep -v grep」しなくてもgrep自身を省く事ができます。 | ||
+ | |||
+ | <code> | ||
+ | # ps auxw | grep [h]ttp | ||
+ | root 23531 0.0 1.1 256620 11448 ? Ss Jun11 0:02 /usr/sbin/httpd | ||
+ | apache 30234 0.0 0.7 257644 7592 ? S 12:23 0:00 /usr/sbin/httpd | ||
+ | apache 30557 0.0 0.7 257644 7624 ? S 12:36 0:00 /usr/sbin/httpd | ||
+ | apache 31189 0.0 0.7 257644 7560 ? S 13:08 0:00 /usr/sbin/httpd | ||
+ | apache 31665 0.0 0.7 257644 7500 ? S 13:32 0:00 /usr/sbin/httpd | ||
+ | apache 31678 0.0 0.7 257644 7508 ? S 13:33 0:00 /usr/sbin/httpd | ||
+ | apache 31702 0.0 0.7 257644 7404 ? S 13:35 0:00 /usr/sbin/httpd | ||
+ | apache 31961 0.0 0.7 257644 8144 ? S 13:51 0:00 /usr/sbin/httpd | ||
+ | apache 31962 0.0 0.7 257644 7488 ? S 13:51 0:00 /usr/sbin/httpd | ||
+ | apache 31963 0.0 0.7 257644 7496 ? S 13:51 0:00 /usr/sbin/httpd | ||
+ | apache 31965 0.0 0.7 257644 7500 ? S 13:51 0:00 /usr/sbin/httpd | ||
+ | </code> | ||
+ | |||
+ | ===== 旧方法 ===== | ||
+ | |||
+ | grep自身が表示されるので、正確なデータを取得する場合は、「grep -v grep」を入れる必要がある。 | ||
+ | |||
+ | <code> | ||
+ | # ps auxw | grep http | ||
+ | root 23531 0.0 1.1 256620 11448 ? Ss Jun11 0:02 /usr/sbin/httpd | ||
+ | apache 30234 0.0 0.7 257644 7592 ? S 12:23 0:00 /usr/sbin/httpd | ||
+ | apache 30557 0.0 0.7 257644 7624 ? S 12:36 0:00 /usr/sbin/httpd | ||
+ | apache 31189 0.0 0.7 257644 7560 ? S 13:08 0:00 /usr/sbin/httpd | ||
+ | apache 31665 0.0 0.7 257644 7512 ? S 13:32 0:00 /usr/sbin/httpd | ||
+ | apache 31678 0.0 0.7 257644 7508 ? S 13:33 0:00 /usr/sbin/httpd | ||
+ | apache 31702 0.0 0.7 257644 7404 ? S 13:35 0:00 /usr/sbin/httpd | ||
+ | apache 31961 0.0 0.7 257644 8148 ? S 13:51 0:00 /usr/sbin/httpd | ||
+ | apache 31962 0.0 0.7 257644 7504 ? S 13:51 0:00 /usr/sbin/httpd | ||
+ | apache 31963 0.0 0.7 257644 7496 ? S 13:51 0:00 /usr/sbin/httpd | ||
+ | apache 31965 0.0 0.7 257644 7500 ? S 13:51 0:00 /usr/sbin/httpd | ||
+ | root 32167 0.0 0.0 65400 840 pts/0 S+ 14:00 0:00 grep http | ||
+ | </code> | ||
+ | |||
+ | |||
+ | {{tag>Unixコマンド 標準}} |