Search code examples
pythonlinuxshellversion

Why m i not getting expected result of python --version?


In linux Debian9, I want comma seperated output of python3 and python2

I am writing this command:

echo $(python3 --version),$(python2 --version)

Output should be like this:

Python 3.7.3,Python 2.7.16

But I am getting output:

Python 2.7.16
Python 3.7.3,

Solution

  • Simplest approach to do this:

    echo $(python3 --version),$(python --version 2>&1)