Get only the Python version (such as 2.7.5) on the CentOS 7 shell

environment

Thing you want to do

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

Conclusion (comments)

python -V 2>&1 | cut -d' ' -f2

What did you get into

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

Get only the Python version (such as 2.7.5) on the CentOS 7 shell
How to get the Python version
How to update the python version of Cloud Shell on GCP
Get the GNOME version
Install Python3.4 on CentOS 6.6
Install Python 2.7.3 on CentOS 5.4
Put the latest version of Python on linux (Debian) on Chromebook
Get information such as GPU usage from Python (nvidia-smi command)
Install Python 3.8 on CentOS 7 (SCL)
[Python] Get the previous month
Install Python 3.8 on CentOS 8 (AppStream)
Set information such as length on the edge of NetworkX
Notes on installing Python on CentOS
How is the progress? Let's get on with the boom ?? in Python
Get started with the Python framework Django on Mac OS X
After calling the Shell file on Python, convert CSV to Parquet.
Get the formula in an excel file as a string in Python
Get the number of readers of a treatise on Mendeley in Python
Install xgboost (python version) on Windows
Get the desktop path in Python
Get only image tweets on twitter
Get the weather with Python requests
Get the weather with Python requests 2
pyenv-change the python version of virtualenv
Get the script path in Python
Ideone> Python version: 3.5 (as of August 29, 2017)
Change the Python version of Homebrew
Set up Python environment on CentOS
Create a python environment on centos
Memorize the Python commentary on YouTube.
Install Python on CentOS using Pyenv
Get the desktop path in Python
Get the host name in Python
Build a python3 environment on CentOS7
Sakura Use Python on the Internet
Python Note: Get the current month
Python version to get unused ports
Install Python on CentOS using pyenv
Get the width of the div on the server side with Selenium + PhantomJS + Python
Get the return value of an external shell script (ls) with python3
About the virtual environment of python version 3.7
[Python] Get the variable name with str
A memo with Python2.7 and Python3 on CentOS
Get Twitter bookmarks on CentOS using Selenium
Connecting from python to MySQL on CentOS 6.4
[Python] Try pydash of the Python version of lodash
Download files on the web with Python
Effective Python was, as the name implies, Effective
[Python] Get the character code of the file
Get the EDINET code list in Python
[Python] A progress bar on the terminal
[Python] Get a list of folders only
[Python] Get the main color from the screenshot
Get only the text from the Django form.
[Python] Get product information such as ASIN and JAN with Amazon PA-API ver5.0
Get the size of the image file on the web (Python3, no additional library required)
Python / subprocess> Symbolic link Implementation to get only the destination file name> os.readlink ()
Get information on the 100 most influential tech Twitter users in the world with python.
How to run GUI programs such as tkinter in Python environment on WSL2
Get coordinate values and keyboard input values by clicking on the python / matplotlib diagram
[Python] I tried to get the type name as a string from the type function