判断是否安装指定jdk版本(python类似)

来源:互联网 发布:中国2016 m2最新数据 编辑:程序博客网 时间:2024/06/08 07:52

#is_installed_java.sh

JAVA_VERSION=`/opt/java/jdk1.8.0_144/bin/java -version 2>&1 |awk 'NR==1{ gsub(/"/,""); print $3 }'`

if [ -z $JAVA_VERSION ];

then echo ERROR; exit 11;

elif [ "1.8.0_144" = "$JAVA_VERSION" ];then

echo "OK"

else

echo "ERROR";exit 12;

fi