0

I would like to assign output of a specific command to variable (nginx -v). My trouble can be seen at printscreen bellow, it still prints output to stdout.

Thank you for your help

enter image description here

kvantour
  • 22,845
  • 4
  • 45
  • 58
tenerife4
  • 31
  • 1
  • 1
    The command `nginx -v` is most likely writing its output to `/dev/stderr`. You can just pick it up with `nginx -v 2>&1`. – kvantour Dec 17 '19 at 10:12

1 Answers1

1
a=$(nginx -v 2>&1)
echo $a

Bash how do you capture stderr to a variable?

0stone0
  • 21,605
  • 3
  • 29
  • 49