I have to install different modules according to the version of Python installed on a machine.
A previous question asked how to do this, but it only prints the result to screen. For instance:
$ python -c 'import sys; print sys.version_info'
sys.version_info(major=2, minor=7, micro=3, releaselevel='final', serial=0)
or rather:
$ python -c 'import sys; print(".".join(map(str, sys.version_info[:3])))'
2.7.3
On a Bash shell, how can I "catch" the printed line above so that I can incorporate its value in an if-statement?
EDIT: OK, now I realize it was very simple. I got stuck initially with:
a=$(python --version)
... because it didn't assign anything to the variable a
, it only printed the version to screen.