How get info into variables from command output

nginx -V sends output to stderr instead of stdout, so you may need to redirect its output to stdout first.

$ nginx -V 2>&1

Then you can grep what you need from nginx -V.

$ nginx -V  2>&1 | grep -E "^nginx"
nginx version: nginx/1.18.0

$ nginx -V  2>&1 | grep -E "^(nginx|configure)"
nginx version: nginx/1.18.0
configure arguments: --with-cc-opt='-g -O2 ... --with-mail_ssl_module