Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. I've tried this:

  1. nginx -V | grep brotli -o --color=always -C9999
  2. nginx -V | grep -o --color=always -C9999 brotli
  3. nginx -V | grep --color=always -C9999 brotli
  4. nginx -V | grep brotli --color=always -C9999
  5. nginx -V | grep brotli -o --color=always
  6. nginx -V | grep -o --color=always brotli
  7. nginx -V | grep --color=always brotli
  8. nginx -V | grep brotli --color=always

But it simply doesn't highlight text, only meaningless wall of white text that is nginx compile options. $PS1 is colored, so terminal isn't inherently broken!


1 Answers

You need to redirect stderr

nginx -V 2>&1 | grep --color=always -e 'http'

Learn more about 2>&1 here: In the shell, what does " 2>&1 " mean?

like image 107
0stone0 Avatar answered Nov 28 '25 17:11

0stone0



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!