In bash, I wish to check whether Python 2.7 is installed. While searching SO I found this: How do I test (in one line) if command output contains a certain string?
In bash, I have this:
python --version
Python 2.7.11
And so I tried this:
[[ $(python --version) =~ "2.7" ]] || echo "I don't have 2.7"
Python 2.7.11
I don't have 2.7
...which I found strange, as I expected that to work.
I also tried this:
if [[ $(python --version) =~ *2.7* ]]
then
echo "I have 2.7"
else
echo "I don't have 2.7"
fi
...which resulted in:
Python 2.7.11
I don't have 2.7
Hm! What am I doing wrong?