grep使用多个查询条件--或

[root@mail ~]# grep 'usrquota\|grpquota' /etc/fstab
LABEL=/1                /                       ext3    defaults,usrquota,grpquota        1 1
/dev/hda10              /mnt/test1              ext3    defaults,grpquota       1 3
[root@mail ~]#

上面的这个方法是从网上找的。活色的部分可以实现多个条件的或关系查询。

其他方法:

『1』使用多个 -e 参数
如:
netstat -an | grep -E  "ESTABLISHED|WAIT"
注意:
netstat -an | grep -e EST -e WAIT
并列使用多个 -e参数可以实现或条件

『2』使用扩展
如:
netstat -an | grep -E  "ESTABLISHED|WAIT"
注意:
此处的 -E 是大写 ,匹配条件一定要加 引号

猜你喜欢

转载自huyumin.iteye.com/blog/2219954