How to Add a Simple Progress Bar in Shell Script

At times we need to write shell scripts that are interactive and user executing them need to monitor the progress. For such requirements we can implement a simple progress bar that gives an idea about how much task has been completed by the script or how much the script has executed.

To implement it we only need to use the echo command with the following options and a backslash-escaped character.

For the sake of understanding we will use sleep 2 command to represent an ongoing task or a step in our shell script. In a real scenario this could be anything like downloading files creating backup validating user input etc. Also to give an example we are assuming only four steps in our script below which is why we are using 20406080 as progress indicator. This can be adjusted as per the number of steps in a script. For instance a script with three steps can be represented by 336699 or a script with ten steps can be represented by 10-90 as progress indicator.


Read Full Post

News Link:

Linux Chatter is a news aggregator service that curates some of the best Linux, Cloud, Technical Guides, Hardware and Security news. We display just enough content from the original post to spark your interest. If you like the topic, then click on the 'read full post' button to visit the author's website. Use Linux Chatter to find content from amazing authors!

Note: The content provided has been modified and is not displayed as intended by the author. Any trademarks, copyrights and rights remain with the source.

Disclaimer: Linux Chatter sources content from RSS feeds and personal content submissions. The views and opinions expressed in these articles are those of the authors and do not necessarily reflect those of Linux Chatter.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.