linux – 在tail -f中,如何过滤掉具有某些关键字的内容?

我想尾随我的日志.但是,我想过滤掉所有包含这些词语的内容:

“ELB”,“Pingdom”,“健康”

解决方法

我不知道使用awk而不是grep,但这对我有用:
tail -f file.log | grep -Ev '(ELB|Pingdom|Health)'

编辑:正如dmouratiCaleb所指出的那样,为方便起见,您也可以使用egrep而不是grep -E.在某些系统上,这将是指向同一二进制文件的链接,而在其他系统中则是由grep包提供的副本.无论哪种方式,它都可以作为-E开关的替代品.但是,根据GNU grep手册页:

[…]two variant programs egrep and fgrep are available. egrep is the same as grep -E. fgrep is the same as grep -F. Direct invocation as either egrep or fgrep is deprecated,but is provided to allow historical applications that rely on them to run unmodified.

因为它们是同义命令,所以除非你根本没有egrep,否则它归结为偏好.但是为了向前兼容,建议使用grep -E语法,因为其他方法已被正式弃用.

相关文章

/etc/sysctl.conf这个目录主要是配置一些系统信息,/etc/sys...
1.作用 useradd或adduser命令用来建立用户帐号和创建用户的起...
它们都是多模式编辑器,不同的是vim 是vi的升级版本,它不仅...
不管是我们在安装软件还是监测软件的使用性能,我们都要随时...
装好Tomcat7后,发现除了本机能访问外界访问不了,岂有此理。...
修改防火墙配置需要修改 /etc/sysconfig/iptables 这个文件,...