Created
November 2, 2016 10:01
-
-
Save xianghuzhao/a70bc2bb352467c0233bde931812ae5f to your computer and use it in GitHub Desktop.
Get python version in shell
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
get_python_version() { | |
version_str=$(python -V 2>&1) | |
temp=${version_str##* } | |
python_version_major=${temp%%.*} | |
temp=${temp#*.} | |
python_version_minor=${temp%%.*} | |
} | |
get_python_version | |
echo "Python version: ${python_version_major}.${python_version_minor}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment