我正在尝试使用tail -f
查看日志文件,并希望排除包含以下字符串的所有行:
"Nopaging the limit is"` and `"keyword to remove is"
我可以像这样排除一个字符串:
tail -f admin.log|grep -v "Nopaging the limit is"
但是如何排除包含string1
或string2
的行呢?
发布于 2016-11-02 07:50:59
grep -Fv -e 'Nopaging the limit is' -e 'keyword to remove is'
-F
按文字字符串匹配(而不是正则表达式)
-v
反转匹配
-e
允许多个搜索模式(所有文字和倒排)
发布于 2014-02-13 16:30:01
另一个选择是创建一个排除列表,当你有一长串要排除的东西时,这是特别有用的。
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
发布于 2013-04-25 18:49:43
egrep -v "Nopaging the limit is|keyword to remove is"
https://stackoverflow.com/questions/16212656
复制相似问题