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.