[英]Piping nginx -V to grep doesn't color matches
nginx/1.17.3, GNU grep 2.27 and xterm-256color capable terminal (Xfce terminal) for some reason doesn't provide colored matches in its output. nginx/1.17.3、GNU grep 2.27 和支持 xterm-256color 的终端(Xfce 终端)出于某种原因在其输出中不提供彩色匹配。 I've tried this:我试过这个:
But it simply doesn't highlight text, only meaningless wall of white text that is nginx compile options.但它根本不突出显示文本,只有毫无意义的白色文本墙,即 nginx 编译选项。 $PS1 is colored, so terminal isn't inherently broken! $PS1 是彩色的,所以终端本身并没有损坏!
You need to redirect stderr
您需要重定向stderr
nginx -V 2>&1 | grep --color=always -e 'http'
Learn more about 2>&1
here: In the shell, what does " 2>&1 " mean?在此处了解有关2>&1
更多信息: 在 shell 中,“2>&1”是什么意思?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.