Tuesday, April 12, 2022

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

Issue

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)


Answered By - Khawar
Answer Checked By - Katrina (WPSolving Volunteer)