Created
January 20, 2015 17:05
-
-
Save mattvryan/c99c19fdc2a6a36ce99a to your computer and use it in GitHub Desktop.
Bash script snippet to check Java version (e.g. in an init script)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
JAVA=`which java` | |
JAVA_VERSION=$("$JAVA" -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/\(.*\)\.\(.*\)\..*/\1\2/') | |
if [ "$JAVA_VERSION" -lt 17 ]; then | |
echo "Invalid Java version found - must be at least 1.7" | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment