标签:三剑客 grep
以查询Apache进程为例
[root@openvas ~]# ps -ef |grep httpd |sort -r -k 8 |tail -5 apache 19785 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19784 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19778 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19762 4416 0 16:28 ? 00:00:00 /usr/sbin/httpd root 21078 11822 0 23:34 pts/0 00:00:00 grep httpd
1. 使用-v选项
$ps -ef |grep httpd |grep -v grep
[root@openvas ~]# ps -ef |grep httpd |grep -v grep |sort -r -k 8 |tail -5 apache 19787 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19785 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19784 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19778 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19762 4416 0 16:28 ? 00:00:00 /usr/sbin/httpd
2. 结合正则匹配
$ps -ef |grep [h]ttpd
[root@openvas ~]# ps -ef |grep [h]ttpd |sort -r -k 8 |tail -5 apache 19787 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19785 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19784 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19778 4416 0 16:29 ? 00:00:00 /usr/sbin/httpd apache 19762 4416 0 16:28 ? 00:00:00 /usr/sbin/httpd
标签:三剑客 grep
原文地址:http://xoyabc.blog.51cto.com/7401264/1695518