scripting - How would i parse a multiline stdout string with a variable in bash script, i am getting error "unary operator expected" -
i have bash script:
#!/bin/bash java_version="1.6.0_17" _stdout=`java -version` if [ $java_version = $_stdout ]; echo "matched" else echo "not matched" fi
i 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 match $java_version $_stdout when $_stdout has multiple lines
use quotes.
#!/bin/bash java_version="1.6.0_17" _stdout=`java -version` if [ "$java_version" = "$_stdout" ]; echo "matched" else echo "not matched" fi
Comments
Post a Comment