问题描述
我觉得的grep
的 - 颜色=总是
标记是相当有用的。然而,只有grep的打印用火柴线(除非你要求上下文行)。由于每次打印有一个匹配行,高亮并不因为它可以添加尽可能多的功能。
我真的很想猫
的文件,并看到高亮匹配模式整个文件。
是有一些方法,我可以告诉grep来打印每行而无论是否有相匹配的阅读?我知道我可以写一个脚本在文件的每一行中运行的grep,不过我很好奇,这是否是可能的标准的grep
。
的egrep --color'的模式| $文件
或者如果你坚持使用grep
的grep --color -E'的模式| $文件
I find grep
's --color=always
flag to be tremendously useful. However, grep only prints lines with matches (unless you ask for context lines). Given that each line it prints has a match, the highlighting doesn't add as much capability as it could.
I'd really like to cat
a file and see the entire file with the pattern matches highlighted.
Is there some way I can tell grep to print every line being read regardless of whether there's a match? I know I could write a script to run grep on every line of a file, but I was curious whether this was possible with standard grep
.
egrep --color 'pattern|$' file
or if you insist on using grep
grep --color -E 'pattern|$' file
这篇关于彩色的grep - 查看整个文件,高亮匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!