I have a bash script:
#!/bin/bash
JAVA_VERSION="1.6.0_17"
_STDOUT=`java -version`
if [ $JAVA_VERSION = $_STDOUT ]; then
echo "Matched"
else
echo "Not Matched"
fi
i get the result:
java version "1.6.0_17" OpenJDK Runtime Environment (IcedTea6 1.7.5) (rhel-1.16.b17.el5-x86_64) OpenJDK 64-Bit Server VM (build 14.0-b16, mixed mode) t4.sh: line 8: [: 1.6.0_17: unary operator expected Not Matched
How would i match $JAVA_VERSION with $_STDOUT
when $_STDOUT has multiple lines
Use quotes.