I know following command can show version of python
$ python --version
Result:
Python 3.7.4
I want to extract 3.7.4
only.
So, I attempt to following command using awk
$ python --version | awk '{print $2}'
But result still same as command python --version
:
Python 3.7.4
I also try to specify delimiter space:
$ python --version | awk -F' ' '{print $2}'
Result still same as python --version
:
Python 3.7.4
How do I do?
the reason is that python prints the output on stderr rather than stdout. Solution e.g.:
python --version 2>&1 | awk '{print $2}'