Reputation: 65
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
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