SG213
SG213

Reputation: 65

Redirecting python version output

How do I redirect the output of python version into a text file in linux?

I tried the following:

python --version > old.txt

The text file is getting created but it is empty. Simple question, but beginner here.

Upvotes: 1

Views: 201

Answers (1)

0x777C
0x777C

Reputation: 1047

The Python version is output to stderr rather than stdout which is what your command is writing to the file. In order to write the contents of stderr you will want to write:
python --version 2> old.txt

Upvotes: 4

Related Questions