I have a problem concerning storing the output of a command inside a variable within a bash script.
I know in general there are two ways to do this
either
foo=$(bar)
# or
foo=`bar`
but for the Java version query, this doesn't seem to work.
I did:
version=$(java --version)
This doesn't store the value inside the var. It even still prints it, which really shouldn't be the case.
I also tried redirecting output to a file but this also fails.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…