Using grep with regular expression to filter out matches

后端 未结 2 2082
陌清茗
陌清茗 2021-01-30 10:21

I\'m trying to use grep with -v for invert-match along with -e for regular expression. I\'m having trouble getting the syntax right.

I\'m trying something like

2条回答
  •  忘掉有多难
    2021-01-30 10:53

    You need to escape the pipe symbol when -e is used:

    tail -f logFile | grep -ve "string one\|string two"
    

    EDIT: or, as @Adam pointed out, you can use the -E flag:

    tail -f logFile | grep -vE "string one|string two"
    

提交回复
热议问题