If you get the following results, you want an output of 2.7.5. (I wanted to install the same version as system with pyenv install.)
$ python -V
Python 2.7.5
python -V 2>&1 | cut -d' ' -f2
It looks like a space delimiter, so I thought I could retrieve it with the cut command first. .. ..
$ python -V | cut -d' ' -f2
Python 2.7.5
When I messed with various commands, the output of the command seemed to be the standard error output.
Before receiving comments, I created an intermediate file and output it with cat, but it was unnecessary if I used the "2> & 1" redirect.
Recommended Posts