grep排除多个string
我正在尝试使用尾部-f来查看日志文件,并且想要排除包含以下string的所有行: 
 "Nopaging the limit is"` and `"keyword to remove is" 
我可以排除一个像这样的string:
 tail -f admin.log|grep -v "Nopaging the limit is" 
 但是,如何排除包含string1或string2 。 
两个用grep过滤多行的例子:
 把它放在filename.txt : 
 abc def ghi jkl 
grep命令使用-E选项与一个string中的标记之间的pipe道:
 grep -Ev 'def|jkl' filename.txt 
打印:
 abc ghi 
命令使用-v选项与由parens包围的令牌之间的pipe道:
 egrep -v '(def|jkl)' filename.txt 
打印:
 abc ghi 
另一个select是创build一个排除列表,当你有一长串排除的东西时,这个列表是特别有用的。
 vi /root/scripts/exclude_list.txt 
现在添加你想要排除的内容
 Nopaging the limit is keyword to remove is 
现在使用grep从文件日志文件中删除行并查看未排除的信息。
 grep -v -f /root/scripts/exclude_list.txt /var/log/admin.log 
 egrep -v "Nopaging the limit is|keyword to remove is" 
 grep -Fv -e 'Nopaging the limit is' -e 'keyword to remove is' 
  -F匹配字面string(而不是正则expression式) 
  -v反转比赛 
  -e允许多种search模式(全部是文字和倒序) 
你可以像这样使用普通的grep:
 tail -f admin.log | grep -v "Nopaging the limit is\|keyword to remove is" 
 tail -f admin.log|grep -v -E '(Nopaging the limit is|keyword to remove is)' 
greps可以被链接。 例如:
 tail -f admin.log | grep -v "Nopaging the limit is" | grep -v "keyword to remove is"