Command substitution:
var=$(cat /some/file.txt)
assigns output of cat command to var variable (without printing cat command output to console). Next I can print value of var variable:
echo "$var"
But
var=$(java -version)
or
var=$(fish -v)
will immediately print output of the command to console (even without echo command). Why?
Why var variable has no value now?
How can I assign output of the command (e.g. java -version) to variable?