Get java version in linux using a one liner
Command: java -version
Output:
openjdk version "1.8.0_192" OpenJDK Runtime Environment (Zulu 8.33.0.2-win64) (build 1.8.0_192-b01) OpenJDK 64-Bit Server VM (Zulu 8.33.0.2-win64) (build 25.192-b01, mixed mode)
So, here how do I fetch 1.8.0_192 ?
Use below command, this redirects the stderr to stdout and then filters the java version number.
java -version 2>&1|awk -F\" '/version/ {print $2}'
0 Comments