For Simplicity, consider the following:
x=$(java --version)
echo "x: $x"
It works how expected showing:
x: openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment Temurin-11.0.13+8 (build 11.0.13+8)
OpenJDK Client VM Temurin-11.0.13+8 (build 11.0.13+8, mixed mode)
What I need is the following:
x=$(java --version)
echo "x: $x"
echo "The '???' command was executed"
Therefore the output should be
x: openjdk version "11.0.13" 2021-10-19
OpenJDK Runtime Environment Temurin-11.0.13+8 (build 11.0.13+8)
OpenJDK Client VM Temurin-11.0.13+8 (build 11.0.13+8, mixed mode)
The 'java -version' command was executed
With what can be replaced ???
?
I already do a research and I found about set +x/-x
but does not apply here in a 100%
echo $x
print output with newlines? – Arkadiusz Drabczyk Feb 13 '22 at 15:23-version
vs--version
in some way - I did realizeecho $x
prints nothing (I just commented) - the output comes from the command itself – Manuel Jordan Feb 13 '22 at 15:29