1

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.

asked May 18, 2019 at 0:31
1

1 Answer 1

4

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

answered May 18, 2019 at 0:34
Sign up to request clarification or add additional context in comments.

2 Comments

Any reason why it gets output to the STDERR stream?
Not particularly, some programs just prefer to use stderr to print meta-information (as well as the usual warnings and error messages).

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.