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.
-
Possible duplicate of Redirect stdout to a file in Python?, How to redirect stderr in Python?, Temporarily Redirect stdout/stderr, Redirect stderr and stdout in Bash, etcjww– jww2019年05月18日 02:22:42 +00:00Commented May 18, 2019 at 2:22
1 Answer 1
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
lang-py