Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1778881
  • 博文数量: 276
  • 博客积分: 1574
  • 博客等级: 上尉
  • 技术积分: 2894
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-26 23:23
个人简介

生活的美妙在于,不知道一下秒是惊艳还是伤神,时光流转,珍惜现在的拥有的时光

文章分类

全部博文(276)

文章存档

2017年(17)

2016年(131)

2015年(63)

2013年(2)

2012年(32)

2011年(31)

分类: LINUX

2012-03-07 10:56:17

经常会使用grep过滤一些进程来快速操作或写入脚本中执行命令,但grep出的输出会带有grep 本身的命令,所以有必要将其屏蔽

  1. [talen@BJB0300 ~]$ ps alx |grep opera
  2. 0 1000 4125 1439 20 0 381332 166116 poll_s Sl ? 0:24 /usr/lib/opera/opera
  3. 0 1000 4141 4125 20 0 261004 49900 poll_s Sl ? 0:14 /usr/lib/opera//operapluginwrapper 111 114 /usr/lib/flash-plugin/libflashplayer.so
  4. 0 1000 4142 4125 20 0 3396 252 poll_s S ? 0:00 /usr/lib/opera//operaplugincleaner 4125
  5. 0 1000 4225 4164 20 0 6292 800 pipe_w S+ pts/1 0:00 grep --color=auto opera

我知道的有两种方式可以操作,都挺方便的。

一。使用grep -v grep 

  1. [talen@BJB0300 ~]$ ps alx |grep opera|grep -v grep
  2. 0 1000 4125 1439 20 0 381336 168252 poll_s Sl ? 0:28 /usr/lib/opera/opera
  3. 0 1000 4141 4125 20 0 261004 56176 poll_s Sl ? 0:18 /usr/lib/opera//operapluginwrapper 111 114 /usr/lib/flash-plugin/libflashplayer.so
  4. 0 1000 4142 4125 20 0 3396 252 poll_s S ? 0:00 /usr/lib/opera//operaplugincleaner 4125
  5. [talen@BJB0300 ~]$


二。使用中括号

  1. [talen@BJB0300 ~]$ ps alx |grep [o]pera
  2. 0 1000 4125 1439 20 0 381368 168260 poll_s Sl ? 0:30 /usr/lib/opera/opera
  3. 0 1000 4141 4125 20 0 261004 63348 poll_s Sl ? 0:20 /usr/lib/opera//operapluginwrapper 111 114 /usr/lib/flash-plugin/libflashplayer.so
  4. 0 1000 4142 4125 20 0 3396 252 poll_s S ? 0:00 /usr/lib/opera//operaplugincleaner 4125
  5. [talen@BJB0300 ~]$

意思是过滤含有中括号的任意字符串与中括号外面的字符串组成的组合字体串的行。

阅读(14999) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~