Skip to content

Instantly share code, notes, and snippets.

@sahal
Created April 10, 2016 22:47
Show Gist options
  • Select an option

  • Save sahal/6939db90e9fecdc0c8bc60edc4fcf160 to your computer and use it in GitHub Desktop.

Select an option

Save sahal/6939db90e9fecdc0c8bc60edc4fcf160 to your computer and use it in GitHub Desktop.
figure out python version
#!/bin/bash
# basic launcher
set -e
set -u
python_path="$(which python)"
#python_path="/usr/bin/python"
# figure out python version (might be useful in the future)
python_version=$($python_path --version 2>&1)
python_2_str="^Python 2"
python_3_str="^Python 3"
if [[ $python_version =~ $python_3_str ]]; then
echo "Python 3 found!"
elif [[ $python_version =~ $python_2_str ]];then
echo "Python 2 found!"
else
echo "Unknown version of Python found, please set \$python_path"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment