title: How to: Progress bar in bash
body: <p>I want to show a progress bar during a bash operation in a specific format something similar to the following:</p>
  
  <pre><code>[###########](40%)
  </code></pre>
  
  <p>after update it should become </p>
  
  <pre><code>[###############](50%)
  </code></pre>
  
  <p>and then similarly reach upto <code>100%</code></p>
  
  <p>Is there any way to achieve this</p>
  
  <p>I wrote the following bash program but i don't know how to show the percentage in this on same line:</p>
  
  <pre><code>#!/bin/bash
  {
      echo -n "["
      for ((i = 0 ; i &lt;= 100 ; i+=6)); do
          sleep 0.05
          echo -n "###"
      done
      echo -n "]"
      echo
  }
  </code></pre>
  
  <p>Let's assume that a certain number of operations are being performed in a loop and after the completion of each operation, I want to report some progress. I don't want to install <code>pv</code> or any other utilities that does not come with default <code>Ubuntu 12.04</code> installation.</p>