I need to get the java version number, for example "1.5", from python (or bash).
I would use:
os.system('java -version 2>&1 | grep "java version" | cut -d """ -f 2')
But that returns 1.5.0_30
It needs to be compatible if the number changes to "1.10" for example.
I would like to use cut or grep or even sed.
It should be in one line.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…