LinuxCommandLibrary

tqdm

Display progress bars for loops and iterables

TLDR

Show iterations per second and use stdout afterwards

$ [seq 10000000] | tqdm | [command]
copy

Create a progress bar
$ [seq 10000000] | tqdm --total [10000000] | [command]
copy

Create an archive out of a directory and use the file count of that directory to create a progress bar
$ zip [[-r|--recurse-paths]] [path/to/archive.zip] [path/to/directory] | tqdm --total $(find [path/to/directory] | wc [[-l|--lines]]) --unit files --null
copy

Create an archive with tar and create a progress bar (system agnostic, GNU tar uses stdout while BSD tar uses stderr)
$ tar vzcf [path/to/archive.tar.gz] [path/to/directory] 2>&1 | tqdm --total $(find [path/to/directory] | wc [[-l|--lines]]) --unit files --null
copy

SYNOPSIS

tqdm [options] command [command arguments]

PARAMETERS

--version
    Show program's version number and exit.

-h, --help
    Show help message and exit.

--desc=TEXT
    Prefix for the progress bar.

--total=VALUE
    Total number of expected iterations.

--unit=TEXT
    Unit of measurement (e.g., 'files', 'bytes').

--unit_scale
    Automatically scale the unit (e.g., 1024 bytes=1 KB).

--unit_divisor=VALUE
    Divisor for automatically scaled units (default: 1000).

--leave
    Leave the progress bar on the screen after completion.

--disable
    Disable the display of the progress bar.

--ascii
    Force ASCII output (no Unicode characters).

--bytes
    Shorthand for '--unit=byte --unit_scale'.

--file=FILE
    Output stream for the progress bar (default: stderr).

--dynamic_ncols
    Resize progress bar to fit the terminal window.

--mininterval=VALUE
    Minimum progress display update interval (in seconds).

--delim=TEXT
    Column delimiter (default: space).

--write_bytes
    Write bytes (rather than Unicode).

--no-write_bytes
    Do not write bytes (rather than Unicode).

--verbose
    Print some statistics after completion/interruption.

DESCRIPTION

The tqdm command is a versatile and easy-to-use tool for adding progress bars to any command-line application. tqdm (from the Arabic word *taqaddum* meaning 'progress') allows you to monitor the execution of long-running processes, providing visual feedback on the progress, estimated time remaining, and iteration speed. It can wrap around any iterable object, automatically updating the progress bar as the process iterates. This significantly improves the user experience when dealing with tasks like large file processing, data analysis scripts, or network operations. tqdm intelligently handles various output environments, including terminals, Jupyter notebooks, and web consoles, ensuring optimal display and performance. It is commonly used by developers and data scientists to enhance their command-line workflows and provides valuable insights into the performance of their scripts and applications.

USAGE EXAMPLES

tqdm command
Wraps the output of a command with a progress bar.
tqdm --total 100 command
Specifies the total number of iterations to expect.

INTEGRATION

tqdm can also be used as a library within Python scripts, allowing for more fine-grained control over the progress bar's behavior and appearance.

SEE ALSO

pv(1), watch(1)

Copied to clipboard