Skip to content

Instantly share code, notes, and snippets.

@h8rt3rmin8r
Created January 27, 2019 10:44
Show Gist options
  • Save h8rt3rmin8r/9fac9b710780f28b9675ac99f2ac4bb3 to your computer and use it in GitHub Desktop.
Save h8rt3rmin8r/9fac9b710780f28b9675ac99f2ac4bb3 to your computer and use it in GitHub Desktop.
Check the versions of your system's locally installed Python2 and Python3
#! /bin/bash
# pyv - Check the versions of the locally installed Python2 and Python3
# Created by h8rt3rmin8r on 20190127
# FUNCTION DECLARATIONS
function py2v() {
# Check the version of the local Python2
python2 --version &> py2v-temp
cat py2v-temp
rm py2v-temp
return
}
function py3v() {
# Check the verion of the local Python3
python3 --version
return
}
# VARIABLE DECLARATIONS
PY2_V="$(py2v)"
PY3_V="$(py3v)"
# EXECUTE OPERATIONS
if [[ "x$1" == "x" ]];
then
echo "Python2 Version: ${PY2_V}"
echo "Python3 Version: ${PY3_V}"
exit 0
fi
if [[ "$1" == "2" || "$1" == "-2" || "$1" == "--python2" || "$1" == "-python2" ]];
then
echo "${PY2_V}"
exit 0
fi
if [[ "$1" == "3" || "$1" == "-3" || "$1" == "--python3" || "$1" == "-python3" ]];
then
echo "${PY3_V}"
exit 0
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment