Tuesday, 22 October 2024

How to Add a Progress Bar to a Shell Script

When writing shell scripts in Bash (or other *NIX shells), adding a progress bar can improve the user experience, especially when executing long-running tasks like file transfers, backups, or compressions. This post explores several techniques to implement progress bars, with different examples from the ones you’ve seen before.

1. Simple Progress Bar Using printf

A simple and effective method is using printf and \r to update the terminal line. Here’s how you can create a basic progress bar that shows the completion percentage as the task progresses:

#!/bin/bash
Read more »

Labels: