How to suppress output in Google Colaboratory cell which executes a command line script (line starts with `!`) via a function

you can use '%%capture' magic function in a cell(without quotes) to suppress the output of that particular cell whether it uses a command-line code or some python code, magic function is basically a property of jupyter notebooks but since google colab is built over this, it will work there also. eg:


Use capture_output from python's utilities:

from IPython.utils import io
for v in range(10):
    with io.capture_output() as captured:

For the future, whenever a magic function doesn't suffice, search for the core properties being accessed and access them yourself.

Answer sourced from: How do you suppress output in IPython Notebook?