I'm new to Bash and trying to store eval command output in a variable. This is my code to check Java version:
javaPath="/opt/Java/i386/jre1.8.0_181/bin/Java -version"
output=eval $javaPath
echo "Java version is: $output"
Output:
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build ...)
Java HotSpot(TM) 64-Bit Server ...
Java version is:
Question: how can I store command output in $output?