bash – 如何使用grep反向搜索多个文本字符串

我正在尝试过滤出几个在我的日志文件中不断重复的文本块.例如
grep -v ("string one that I don't want" \| "string two that I don't want") file.log

我尝试了几种变化,并尝试调整白色空间.有时它会滤除第一个字符串,有时也不会.使用grep过滤掉多个文本块的正确格式是什么?

您可以在grep中多次使用-e选项来跳过多个搜索项目:
grep -v -e "string one that I don't want" -e "string two that I don't want" file.log

或者使用egrep使用正则表达式

egrep -v 'string one|string two' file.log

相关文章

用的openwrt路由器,家里宽带申请了动态公网ip,为了方便把2...
#!/bin/bashcommand1&command2&wait从Shell脚本并行...
1.先查出MAMP下面集成的PHP版本cd/Applications/MAMP/bin/ph...
1、先输入locale-a,查看一下现在已安装的语言2、若不存在如...
BashPerlTclsyntaxdiff1.进制数表示Languagebinaryoctalhexa...
正常安装了k8s后,使用kubect工具后接的命令不能直接tab补全...