Linux中grep 或 与

在查看服务线上运行日志时,与grep打交道的次数很多。下面总结了一下 grep中的  或  和 且 的用法

 

1.普通用法

 

   grep "keyword"

  例如:

   cat  run.log | grep "test"

 

2.“与”操作(多次筛选)

  grep "test" | grep "mq"

例如:

  cat  run.log | grep "test" | grep "mq"

 

3.“或”操作

  grep -E  "test|mq"

  egrep   "test|mq"


 参考
原文链接:https://blog.csdn.net/londa/article/details/117619792

posted @ 2022-07-28 17:45  蜗牛学编程  阅读(1640)  评论(0编辑  收藏  举报