Many Debian users use grep regularly. But did you know that grep can highlight the text it matches in color?
Much like ls, grep supports the use of color in its output, controlled by a --color option. By default, grep outputs matching lines, but does not indicate what portion of the line matched. With --color=auto, grep will highlight the matching portion of the line in color when it outputs to a terminal, while avoiding the use of any potentially-harmful terminal control sequences when standard output goes somewhere else (like a file or pipe). If you like the colorful grep, you can simply export GREP_OPTIONS='--color=auto' in your shell startup script.
grep's default highlight uses a red color. You can change this color by setting the GREP_COLOR environment variable to a different escape sequence fragment. I use export GREP_COLOR='1;32', which produces a bright green.
https://debian-administration.org/article/460/grep_highlighting_matches_in_color
本文介绍了一种使用grep命令在Debian系统中高亮显示匹配文本的方法。通过使用--color选项,可以在终端输出中为匹配部分添加颜色高亮。默认情况下,grep仅输出匹配的行,但不指示具体哪些部分匹配。当标准输出被定向到终端时,--color=auto选项会让grep使用安全的颜色高亮,避免在输出到文件或管道时产生潜在有害的终端控制序列。

被折叠的 条评论
为什么被折叠?



