Python Script
Got into this while learning about Advent of Code. https://realpython.com/run-python-scripts/
You can redirect the output by doing
python hello.py > output.txt
The above is called Stream Redirection.
If output.txt
doesn’t exist, then it’s automatically created. On the other hand, if the file already exists, then its contents will be replaced with the new output.
Finally, if you want to add the output of consecutive executions to the end of output.txt
, then you must use two angle brackets (>>
) instead of one, just like this:
python3 hello.py >> output.txt