-1

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,
Khawar
  • 1
  • 2
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Mar 30 '22 at 09:35
  • `python --version` outputs the Python version and a newline. If you don't want it, you'd have to strip the trailing newline. – khelwood Mar 30 '22 at 09:36
  • [Bash: Strip trailing linebreak from output](https://stackoverflow.com/q/12524308/3890632) perhaps – khelwood Mar 30 '22 at 09:38
  • Subshells are executed from right to left. `python3 --version | tr "\n" ","; python2 --version` will do the job. – Richard Neumann Mar 30 '22 at 09:44
  • @RichardNeumann understood the problem exactly, and your solution is also giving required string, but it I m looking for more simplest way. otherwise your answer is correct – Khawar Mar 30 '22 at 09:53

1 Answers1

0

Simplest approach to do this:

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