我只是试图让grep显示所有的行,但匹配的应该有匹配的文字着色。 具体来说,我需要这样的东西:
tail -f file.log | grep --color Exception
不幸的是我没有看到任何grep的选项,将同时显示不匹配的行和匹配的行(与颜色)。 有没有其他的工具在Unix / Linux的这将允许这个?
一个解决方法是使用上下文选项和大量的行数:
tail -f file.log | grep -C 1000 --color Exception
如果你有ack它有一个选项:
tail -f file.log | ack --color --passthru Exception