0

I am using bash shell and expr command.Below is my scripts:

v=`java -version`

echo 'check java platform...'

echo `expr match "$v" 'java'`

Can't match java substring, just got 0. But if I use this : v='java version "1.6.0_34"' I got the correct result:4

Why? How to fix it?

1 Answer 1

2

try this:

export v=`java -version 2>&1`
echo $v
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Could explain a bit, any document?
I tried v=`java -version` and v has nothing, then it must be in stderr.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.