1

I want to automatically record my python version in a computerinfo file. However

python2 -V >> myfile

prints only to the console but not to myfile. How can I get the output into a file?

Curiously, for python3 -- python3 -V >> myfile -- this works as I expected.

I am on Ubuntu 16.04 and I use the bash shell.

Jan
  • 4,932
  • 1
  • 26
  • 30

1 Answers1

1

There is a bug in python2 -V, that prints the version as stderr instead of stdout. Try to redirect the stderr like:

python2 -V 2>> myfile
Frederico Martins
  • 1,081
  • 1
  • 12
  • 25