12. Linux¶
12.1. output to screen, stderr and text file¶
Output to both stderr and displayed at terminal/console:
$ command 2>&1 | tee logfile.txt
Chart for StdOut/StdErr
|| visible in terminal || visible in file || existing
Syntax || StdOut | StdErr || StdOut | StdErr || file
==========++==========+==========++==========+==========++===========
> || no | yes || yes | no || overwrite
>> || no | yes || yes | no || append
|| | || | ||
2> || yes | no || no | yes || overwrite
2>> || yes | no || no | yes || append
|| | || | ||
&> || no | no || yes | yes || overwrite
&>> || no | no || yes | yes || append
|| | || | ||
| tee || yes | yes || yes | no || overwrite
| tee -a || yes | yes || yes | no || append
|| | || | ||
n.e. (*) || yes | yes || no | yes || overwrite
n.e. (*) || yes | yes || no | yes || append
|| | || | ||
|& tee || yes | yes || yes | yes || overwrite
|& tee -a || yes | yes || yes | yes || append
n.e -> won’t fit in this space
12.2. Upgrade Python in Ubuntu 18+¶
# check version
$ python3 --version # or
$ python --version
# install python 3.8
$ sudo apt update -y
$ sudo apt install python3.7
# add python 3.7 and python 3.8 to update-alternatives
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1
$ sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 2
# update python3 to point to python 3.8
$ sudo update-alternatives --config python3
$ sudo update-alternatives --config python3
# You will get the following output
There are 2 choices for the alternative python3 (providing /usr/bin/python3).
Selection Path Priority Status
------------------------------------------------------------
* 0 /usr/bin/python3.7 1 auto mode
1 /usr/bin/python3.7 1 manual mode
2 /usr/bin/python3.8 2 manual mode
Press <enter> to keep the current choice[*], or type selection number:
# update by pressing 2
Alternative update choice, create a new symlink to python 3.8:
$ sudo rm /usr/bin/python3
$ sudo ln -s python3.8 /usr/bin/python3
Thanks to ‘<https://dev.to/serhatteker/how-to-upgrade-to-python-3-7-on-ubuntu-18-04-18-10-5hab>’_